public class TemplatePruner
extends java.lang.Object
implements java.io.Serializable
The methods in this class are accessible from within a template via the
$prn
variable.
Modifier and Type | Field and Description |
---|---|
private static java.util.Hashtable<java.lang.String,java.util.regex.Pattern> |
cvRegExPatterns
A cache of compiled regular expression patterns.
|
private static long |
serialVersionUID
The class' serialization version id.
|
Constructor and Description |
---|
TemplatePruner() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
cleanHtml(java.lang.String s)
Returns a cleaned copy of a given string of HTML.
|
static java.lang.StringBuilder |
getHtmlBody(java.lang.StringBuilder sb)
Extracts the HTML body from a string.
|
static java.util.ArrayList<java.lang.String> |
getHtmlScripts(java.lang.StringBuilder sb)
Extracts the HTML script definitions from a string.
|
static java.util.ArrayList<java.lang.String> |
getHtmlStyles(java.lang.StringBuilder sb)
Extracts the HTML style sheet definitions from a string.
|
static java.lang.String |
getHtmlTitle(java.lang.StringBuilder sb)
Extracts the HTML title from a string.
|
static java.lang.String |
removeWhitespace(java.lang.String s)
Removes all whitespace from a string.
|
private static final long serialVersionUID
private static java.util.Hashtable<java.lang.String,java.util.regex.Pattern> cvRegExPatterns
public static java.lang.String cleanHtml(java.lang.String s)
#parse
macro whereby the string to be processed is
a parsed template that is about to be merged with another template. The
template being merged could contain code that would result in invalid HTML
after the merge. A cleaned copy has all potentially damaging code removed
(i.e. extra <head>
tags, extra <body>
tags, etc.).s
- (String) The string to process.public static java.lang.StringBuilder getHtmlBody(java.lang.StringBuilder sb)
<body>
and </body>
tags. The <body>
and </body>
tags are also discarded.sb
- (StringBuilder) The string to process.public static java.util.ArrayList<java.lang.String> getHtmlScripts(java.lang.StringBuilder sb)
<script...
and </script
tags. The
tags are included in the results. Each element of the results represents
a single script definition, which may be a link to a script file or may be
the actual script code.sb
- (StringBuilder) The string to process.public static java.util.ArrayList<java.lang.String> getHtmlStyles(java.lang.StringBuilder sb)
<link
tag and end with
.css">
. Each element of the results represents a single style
sheet definition.sb
- (StringBuilder) The string to process.public static java.lang.String getHtmlTitle(java.lang.StringBuilder sb)
<title>
and </title>
tags. The <title>
and </title>
tags are also discarded.sb
- (StringBuilder) The string to process.public static java.lang.String removeWhitespace(java.lang.String s) throws java.lang.Exception
String.trim()
).<!--
and end with -->
.s
- (String) The string to process.java.lang.Exception
- - if an error occurs during processing.