24
votes

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

2 Answers

40
votes

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
votes

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

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

or

<#if false>comment</#if>