Major
Detail
Bugfix
Major
Detail
HTML can be embedded in TLScript in {{...}}. In turn, script expressions can be embedded in {`...}`, whose evaluation result is output.
The attribute types Macro, Template and Report use this HTML mode of TL-Script as HTML template language with embedded expressions. The document is actually HTML, but may contain TL-Script expressions enclosed in {`...}` in attributes or text content.
<div> The answer is <b>{6 * 7}</b>. </div>
The template document remains legal HTML and can be edited in a browser (or WYSIWYG editor) - at least as long as it is about simple expressions (which can be written as plain text).
However, if you want to generate dynamic HTML in the embedded script and switch back to HTML mode with {{...}}}, the whole document will either be completely unreadable, because you have to quote all <-characters, or it will no longer be displayable as HTML:
<div> My favorite numbers are: </div> <ul> { count(1,100).filter(x -> $x % 7 == 0).map(x -> {{ <li>{$x}</li> }} ) } </ul>
This document contains text between <ul> and the one <li>...</li> and is therefore no longer legal HTML. To be able to store such scripts in normal HTML attributes, it would be better to be able to mark up an embedded script using an HTML script tag:
<div> My favorite numbers are: </div> <ul> <script type="text/tlscript"> count(1,100).filter(x -> $x % 7 == 0).map(x -> {{ <li>{$x}</li> }} ) </script> </ul>
Although an HTML editor will not readily display the script content in the preview then either, at least the script can be edited in the editor's source view that way.
Test
- /com.top_logic.model.search/src/test/java/test/com/top_logic/model/search/expr/TestHtmlMacroExpansion-testEmbeddedScriptTag.script.html