Vasiliy Pispanen
Vasiliy Pispanen

Reputation: 227

How to process freemarker template from variable inside template?

Simple example:

<div>${item.content}</div>

But inside of item.content variable may exist another template code, such as

<#if otherItem.image??><div class ...>...</#if>

Is that possible to tell freemarker compile this code inside variable?

Upvotes: 3

Views: 398

Answers (1)

ddekany
ddekany

Reputation: 31112

?interpret creates a directive from a string. Note that it doesn't call the directive. Expressions that evaluate to directive can be called with <@someExpression />. Putting these together you get:

<div><@item.content?interpret /></div>

Upvotes: 4

Related Questions