content
An HTML content command that brings text or document content into its host element.
The resolved value of its primary attribute may be a File, an Online template Part, a String, or any other kind of value that then gets converted into a String.
If the value is a File, the file is expected to be a HTML document or an Online template. In the case of a HTML document, a specified part or all of the document's body content is imported into the host element. An Online template value causes a logic evaluation to happen, as described below.
If the value is a Part of the Online template this attribute is in, the content of the document of that Part is automatically evaluated and the result imported into the host element. If the Part doesn't contain document content, this attribute produces an error.
If the value is a String and the String contains at least one character, that String is simply set as the text content of the host element. Should there be any EL-expressions in that text content, those expressions are replaced by text representations of the values they resolve into. If the resolved value is an empty String - one with no characters - it is treated in the same way as if there was no value defined (this behavior may be altered through the
composeContent
command initiating the evalution of this command).If the value is of any other type, its text representation is set as the text content of the host element. If the value is undefined ie.
null
, the host element will not be affected in any way.
With Online template values, the end result is HTML content being imported in a similar manner, but the content to be imported is defined by the template's logic. The Compose Flow of the template is run with "import" as the initiating event. The content to import is the result of the last composeContent command run within the Flow. A composeContent
within the Flow may also define itself to be the import result's producer through an attribute. The result is then expected to be HTML and that HTML is imported into the host element in the same way as if the resolved value was a HTML file to begin with.
This command has a priority of 15.
As content
may trigger the evaluation of another HTML template by having an Online template or Part as its resolved value, it can cause other content
commands to be evaluated. Those content
commands in that other template may not trigger further template evaluations to occur, and so if any of them would have an Online template or Part as the resolved value, an error would occur.
Secondary attributes
content-append | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
If this attribute's value resolves into If not defined, the value of |
content-format | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Specifies a Format that takes the value to output and formats it into a String as according to its formatting rules. This attribute doesn't have any effect if the output value is a File or an Online template Part. The resolved String is expected to the name of a Format defined earlier in the logic. |
content-parser | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
If the resolved value of this attribute is the name of a Parser, the value to output is first converted into a String (if it isn't one already) and then parsed into another type of value by the Parser. This attribute doesn't have any effect if the output value is a File or an Online template Part. If both If undefined or if the named Parser cannot be found, the value retains its original type. |
content-replace | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
If this attribute's value resolves into This attribute has no effect if the new content is not provided as a File. Text content is always placed inside the host element. If not defined, the value of |
content-target | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Defines the content that is imported from a HTML document file. The resolved String is treated as a class name and the content to import is the first element within the document that represents this class. This attribute has no effect if the new content is not provided as a File. Text content is always brought into the host element in its entirety. If not defined, all content within the HTML document's body is imported. If the document does not have a |
Examples
The content
command may be placed into any HTML element that can contain text, such as span
:
<span dyn-content="sampleText"/>
If importing a HTML file, you may only want bring in a specific part of its contents. The content-target
secondary attribute helps with that - in this example, only the first element in the "sampleHTMLDoc" File with class
of "mainBlock" will appear:
<div dyn-content="sampleHTMLDoc" dyn-content-target="mainBlock"/>