Package sunlabs.brazil.template
Class HighlightTemplate
java.lang.Object
sunlabs.brazil.template.Template
sunlabs.brazil.template.HighlightTemplate
- All Implemented Interfaces:
Serializable
,TemplateInterface
Template class for highlighting text that matches a regular expression.
All text between html/xml entities is matched against a regular expression.
For each portion of text that matches the expression, a pair of
html/xml tags is added on either side of all matched text.
Highlighting is automatically turned off inside of head, script, style,
and server tags.
Properties. These are recomputed for every page that
highlight
changes.
- highlight
- A regular expression that with match any text between entities.
- tag
- the html/xml tag pair that will be added before and after all text maching "highlight", above. The default is "<font> ..... </font>
- options
- the set of name=value options that will be added to the starting tag of the tag pair, above. The default is "color=red".
- matchCase
- If specifies, matches are case sensitive. The default is to ignore case when matching.
- substitute
- The string to substitute for the matched text.
This is for advanced uses. If specified, the values
for
tag
andoptions
are ignored. The default is: <${tag} ${options}>&</${tag}> The format of the string is a regular expression substitution string, which supports ${} style variable substitutions from the request properties. - mustHighlight
- If not set, the entire document is surrounded
by implicit
highlight
tags. If set no highlighting will take place until an actualhighlight
tag is present. - exit
- If set, the template "init" method will return false, and no further processing will take place. This is useful if this template is used by itself.
The following html tags are processed:
- highlight
- /highlight
- Only text between these tags is considered for highlighting.
- nohighlight
- /nohighlight
- Temporarily undoes the effect of a
highlight
tag. In the current implementation,highlight
andnohighlight
don't nest.
- Version:
- 2.1 HighlightTemplate.java %V% 0
- Author:
- Stephen Uhler
- See Also:
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
init
(RewriteContext hr) This gets called at every page, at the beginning.void
string
(RewriteContext hr) Gets all text between tags - highlighting it appropriately.void
Don't do highlight inside the following sectionsvoid
The special entitieshighlight
andnohighlight
may be used to turn highlighting on or off in certain areas.void
void
void
void
void
void
void
void
void
void
-
Constructor Details
-
HighlightTemplate
public HighlightTemplate()
-
-
Method Details
-
init
This gets called at every page, at the beginning. If this is our first time, get the config stuff out of the request properties.- Specified by:
init
in interfaceTemplateInterface
- Overrides:
init
in classTemplate
-
string
Gets all text between tags - highlighting it appropriately. To restrict the tag set, define the entities and set the shouldHighlight flag appropriately. -
tag_head
Don't do highlight inside the following sections -
tag_slash_head
-
tag_script
-
tag_slash_script
-
tag_style
-
tag_slash_style
-
tag_server
-
tag_slash_server
-
tag_highlight
The special entitieshighlight
andnohighlight
may be used to turn highlighting on or off in certain areas. -
tag_slash_highlight
-
tag_nohighlight
-
tag_slash_nohighlight
-