Comments in freemarker template and smooks

29.9k views Asked by At

I am working on a freemarker template and here is a sample.

<Grantor>
    <UniqueID>${(currentGrantorIndex)!?string}</UniqueID> // want to comment this line
    <Entity>${(grantor.entityTypeName)!?string}</Entity>
</Grantor>

I want to know how to write comments or comment out few lines in freemarker templates. Any idea?

2

There are 2 answers

0
obourgain On BEST ANSWER

Comment in freemarker are delimited by <#-- and -->. Everything between these delimiters will not be interpreted by freemarker and won't appear in the output.

<Grantor>
    <#-- <UniqueID>${(currentGrantorIndex)!?string}</UniqueID> -->
    <Entity>${(grantor.entityTypeName)!?string}</Entity>
</Grantor>

See freemarker reference here.

0
Rohit On

Another non-standard way of adding comments in freemarker using the if tag:

<#if 1=0>comment</#if>

or

<#if false>comment</#if>