Data AccessCore JavaApp FrameworksViewTestingBuildingDeploymentDev ToolsSecurityOpinions

Thursday, April 9, 2009

Escape Sequence and Raw String Literal for ${} in FreeMarker

I use freemarker to generate JSP's to quickly generate simple CRUD actions. During the development of this code generator I needed a way to escape ${} and print out that string literal.

To indicate that a string literal is a raw string literal, you have to put an r directly before the opening quotation mark or apostrophe-quote.

Example:
${r"${example}"}

will print:
${example}
C:\foo\bar

Anymore questions about FreeMarker? Just ask me by providing a comment and I'll mull over it. Thanks!

2 comments: