OpenWGA 7.6 - OpenWGA Concepts and Features
Design and development » WebTML » Basic conceptsDynamic attributes
Dynamic attribute values are generally introduced by starting and ending the attribute value with curly braces. One example is to simply fill the contents inside those braces with any TMLScript expression:
<tml:item name="{ 'field' + counter }">
This expression is evaluated against the current document context of the WebTML tag. The result of the expression will become the effective value of the attribute.
If you do not want to define the whole attribute dynamically but only parts of it you can prepare this by starting and ending the attribute with square brackets. This will let WebTML scan the content of the attribute for parts embraced by curly brackets, which then are evaluated dynamically. Everything else ist just kept as a string, like in a normal attribute. The square brackets are ignored apart from them introducing this mixed mode. This for example does the same as the example above, but lets only the "counter" variable be evaluated dynamically. The string "field" is just defined straight-forward as static attribute content:
There are various functions to calculate dynamic attribute values documented in WebTML reference. One other example is to start the attribute value with "label:" and continue it with the key of a WebTML label whose language-specific contents should be read as attribute value:
<tml:item name="headline" label="{label:authoring.headline.label}"/>
General rules how dynamic attribute values are used:
- Dynamic attributes are recalculated on each new rendering. If a dynamic attribute is used multiple times on the same page, for example if its tag is contained in some iterating tag, then the attribute will be recalculated each time separately on each iteration.
- If the calculated value is no string it will be converted to one. If it is a List then all elements of the list are converted to strings (if they not already are) and concatenated with a comma as separator (which is quite handy for attributes that expect comma-separated values like options on <tml:input>).