Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dump all values in .vars in Freemarker

I'm attempting to dump all the variables available to my freemarker templates. I'm attempting to use something like:

<#list .vars?keys as prop>
${prop} = ${.vars.get(prop)}

</#list>

I read in the documentation that .vars doesn't support the keys functionality however I'm using the above to show what I'm trying to do.

This is my first day with Freemarker so any advice would be great.

like image 510
Kyle Hayes Avatar asked Jan 20 '11 18:01

Kyle Hayes


1 Answers

I don't think you can list all the variables available to the template. I know you can't list them in Java.

FreeMarker is very well documented. Check out the part on special variables in FreeMarker.

If it's any consolation, you can access the local variables,

<#assign someVar = 12>
<#list .main?keys as var>
    ${var}
</#list>

which outputs

someVar
like image 54
Andy Avatar answered Sep 24 '22 09:09

Andy