
COB-INF.java.interpolation.xsp Maven / Gradle / Ivy
The newest version!
<span class="http"><span class="http"><span class="http"><span class="cpp">Attribute <span class="hljs-keyword">and</span> Text Interpolation</span></span></span></span>
{#Constants.COMPLETE_NAME} allows to use
{##expr}
to replace the value of the Java expression expr
within attribute values and text nodes.
For expression interpolation in text nodes the difference is to
the usual xsp:expr syntax is minor.
For dynamic attribute values, however, interpolation
keeps it much more concise and readable.
String world = "world";
String color = "red";
]]>
String world = "world";
String color = "red";
Just compare this:
Hello simple {#world}!]]>
Hello simple {#world}!
to that:
color:color Hello complex world !]]>
color:color Hello complex world !
Interpolation can also be used in logicsheets:
The XSP expression parser understands nested braces,
single and double quoted strings, and backslash-escaped
quotes and apostrophes.
Expression Result Expected
{#new String[]{}.length}
{#new String[]{}.length}
0
{#new String[]{"}"}.length}
{#new String[]{"}"}.length}
1
{#"'\"}".indexOf('}')}
{#"'\"}".indexOf('}')}
2