Search code examples
macrosfreemarkervelocity

converting macro velocity to freemarker


I have this macro in velocity trying to convert it to a freeMarker template:

    #macro(headerRow $yard $yardName)
    <tr><td class="header" colspan="6">Call List - $yard - $yardName</td></tr>
#end

In freeMaker, I had:

<#macro(headerRow ${yard} ${yardName})>
    <tr><td class="header" colspan="6">Call List - ${yard} - ${yardName}</td></tr>
</#macro>

At the first line it will not like it, not sure where the close tag has to be.


Solution

  • Freemarker macro first line shouldn't have special characters (as $).

    In your case:

     <#macro headerRow yard yardName>
    <tr><td class="header" colspan="6">Call List - ${yard} - ${yardName}</td></tr>
    

    for example <#macro "foo~bar">.... Note that this string literal does not expand interpolations (as "${foo}").