| |
|
| java.lang.Object bsh.servlet.SimpleTemplate
SimpleTemplate | public class SimpleTemplate (Code) | | This is a simple template engine. An instance of SimpleTemplate wraps
a StringBuffer and performs replace operations on one or more parameters
embedded as HMTL style comments. The value can then be retrieved as a
String or written to a stream.
Template values in the text are of the form:
Substitutions then take the form of:
template.replace( "NAME", value );
Two static util methods are provided to help read the text of a template
from a stream (perhaps a URL or resource). e.g.
author: Pat Niemeyer |
cacheTemplates | static boolean cacheTemplates(Code) | | |
findTemplate | int[] findTemplate(String name)(Code) | | Find the starting (inclusive) and ending (exclusive) index of the
named template and return them as a two element int [].
Or return null if the param is not found.
|
getTemplate | public static SimpleTemplate getTemplate(String file)(Code) | | Get a template by name, with caching.
Note: this should be updated to search the resource path first, etc.
Create a new instance of a template from the specified file.
The file text is cached so lookup is fast. Failure to find the
file is also cached so the read will not happen twice.
|
replace | public void replace(String param, String value)(Code) | | Substitute the specified text for the parameter
|
setCacheTemplates | public static void setCacheTemplates(boolean b)(Code) | | |
|
|
|