Susobh Sugathan
Susobh Sugathan

Reputation: 13

Freemarker : Expression inside Expression

Is there any way that i can use an expression inside expression in Freemarker?

Example: XML FIle

<Document>
<Row>
<item_date>01/01/2015</item_date>
</Row>
<Row>
<item_date>02/01/2015</item_date>
</Row>
</Document>

<#list 0..1 as i>
${Document.Row[${i}].item_date}
</#list>

I want to print as below 01/01/2015 02/01/2015

Any idea?

Thanks in Advance

Upvotes: 0

Views: 2589

Answers (1)

ddekany
ddekany

Reputation: 31112

Like this:

${Document.Row[i].item_date}

Note that if you are using an up-to-date version, you get this error message, which explains why:

You can't use "${" here as you are already in FreeMarker-expression-mode. Thus, instead of ${myExpression}, just write myExpression. (${...} is only needed where otherwise static text is expected, i.e, outside FreeMarker tags and ${...}-s.)

Upvotes: 1

Related Questions