Class JsonStringEscapeDirective
java.lang.Object
org.kuali.rice.krad.uif.freemarker.JsonStringEscapeDirective
- All Implemented Interfaces:
freemarker.template.TemplateDirectiveModel,freemarker.template.TemplateModel
public class JsonStringEscapeDirective
extends Object
implements freemarker.template.TemplateDirectiveModel
A custom FreeMarker directive that adds escapes to nested content to make it valid for enclosure within a JSON
string.
In other words, the content that is generated within this tag should be able to be enclosed in quotes within a JSON document without breaking strict JSON parsers. Note that this doesn't presently handle a wide variety of cases, just enough to properly escape basic html.
There are three types of replacements this performs:
- the quote character '"' is prefixed with a backslash
- newline characters are replaced with backslash followed by 'n'
- carriage return characters are replaced with backslash followed by 'r'
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Field Summary
Fields inherited from interface freemarker.template.TemplateModel
NOTHING -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
JsonStringEscapeDirective
public JsonStringEscapeDirective()
-
-
Method Details
-
execute
public void execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateException, IOException - Specified by:
executein interfacefreemarker.template.TemplateDirectiveModel- Throws:
freemarker.template.TemplateExceptionIOException
-