#ftl strict_syntax=false>
<#assign htmlEscape = "freemarker.template.utility.HtmlEscape"?new(),
jython = "freemarker.template.utility.JythonRuntime"?new(),
utility = "freemarker.testcase.models.TransformHashWrapper"?new()>
FreeMarker: Transformation Test
A simple test follows:
${message}
<@htmlEscape>
${message}
@htmlEscape>
Now try the Utility package:
${utility}
${utility}
Now some nested transforms:
This tests the compress transformation
<@utility.compress>
This tests the compress transformation
@utility.compress>
<#assign html_transform = "freemarker.template.utility.HtmlEscape"?new() />
<#--Using the transform via an instantiation -->
This tests the compress transformation
Now try method and transform interactions:
This isn't a valid XML string.
This isn't a valid HTML string.
A more advanced interaction involves getting a TemplateMethodModel
to initialise a TemplateTransformModel, as follow:
Comment: *
A test string containing quotes: "This isn't a test".
A test string containing amps: Fish & Chips.
A test string containing tags: Fish & Chips.
Comment: *
A test string containing quotes: "This isn't a test".
A test string containing amps: Fish & Chips.
A test string containing tags: Fish & Chips.
Comment: *
A test string containing quotes: "This isn't a test".
A test string containing amps: Fish & Chips.
A test string containing tags: Fish & Chips.
Comment: *
A test string containing quotes: "This isn't a test".
A test string containing amps: Fish & Chips.
A test string containing tags: Fish & Chips.
<#assign captured_output>
print 2+2
# Now we interact with the template environment somewhat.
print ${x} + ${y}
print env['x'] # using a variable from the template
env["message"] = 'I saw the ${z}. It was ${adjective}.'
#assign>
${message}
${captured_output}