Tool for working with escaping in Velocity templates.
It provides methods to escape outputs for Java, JavaScript, HTML, XML and SQL. Also provides methods to render VTL characters that otherwise needs escaping.
String
using Java String rules.
null
if null string input.
Delegates the process to StringEscapeUtils#escapeJava(String) .
If $java
had the following value:
then the following Velocity script:
produces this output:
String
using JavaScript String rules.
null
if null string input.
Delegates the process to StringEscapeUtils#escapeJavaScript(String) .
If $javascript
had the following value:
then the following Velocity script:
produces this output:
String
using HTML entities.
String
, null
if null string input
Delegates the process to StringEscapeUtils#escapeHtml(String) .
If $html
had the following value:
then the following Velocity script:
produces this output:
String
to be suitable to use as an HTTP parameter value.
String
, null
if null string input
Delegates the process to java.net.URLEncoder#encodeURL(String,"UTF-8") .
If $url
had the following value:
then the following Velocity script:
produces this output:
String
using XML entities.
String
, null
if null string input
Delegates the process to StringEscapeUtils#escapeXml(String) .
If $xml
had the following value:
then the following Velocity script:
produces this output:
String
to be suitable to pass to an SQL query.
null
if null string input
Delegates the process to StringEscapeUtils#escapeSql(String) .
If $sql
had the following value:
then the following Velocity script:
produces this output:
String
using the rules for writing Java properties into a properties file.
null
if null string input.
Taken directly from the private method dumpString of java.util.Properties from Apache Harmony. The only difference between this method and the propertyValue method below is; leading spaces will be escaped. If templating a substring of the key then use propertyValue below.
If $propertyKey
had the following value:
then the following Velocity script:
produces this output:
String
using the rules for Java properties.
null
if null string input.
Taken directly from the private method dumpString of java.util.Properties from Apache Harmony.
If $propertyValue
had the following value:
then the following Velocity script:
produces this output:
The following Velocity script:
produces this output:
The following Velocity script:
produces this output:
The following Velocity script:
produces this output:
The following Velocity script:
produces this output:
The following Velocity script:
produces this output:
The following Velocity script:
produces this output:
The following Velocity script:
produces this output:
The following Velocity script:
produces this output:
The following Velocity script:
produces this output:
The following Velocity script:
produces this output: