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
tagandoptionsare 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
highlighttags. If set no highlighting will take place until an actualhighlighttag 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
highlighttag. In the current implementation,highlightandnohighlightdon't nest.
- Version:
- 2.1 HighlightTemplate.java %V% 0
- Author:
- Stephen Uhler
- See Also:
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleaninit(RewriteContext hr) This gets called at every page, at the beginning.voidstring(RewriteContext hr) Gets all text between tags - highlighting it appropriately.voidDon't do highlight inside the following sectionsvoidThe special entitieshighlightandnohighlightmay be used to turn highlighting on or off in certain areas.voidvoidvoidvoidvoidvoidvoidvoidvoidvoid
-
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:
initin interfaceTemplateInterface- Overrides:
initin 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 entitieshighlightandnohighlightmay be used to turn highlighting on or off in certain areas. -
tag_slash_highlight
-
tag_nohighlight
-
tag_slash_nohighlight
-