|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.freehep.util.template.TemplateEngine
A very simple template engine. The template engine takes input and transforms it by looking for tags in the document, and replacing them with values provided by a set of ValueProviders.
Example of HTML template:
<html>
<head>
<title>{v:title}</title>
</head>
<body>
Welcome {v:name} to Simple Template Example
<table>
<tr bgcolor="d0d0d0"><th>Author</th><th>Title</th><th>Year</th></tr>
<t:book>
<tr>
<td><a href="#">{v:author}</a></td>
<td><a href="#">{v:title}</a></td>
<td><a href="#">{v:year}</a></td>
</tr>
</t:book>
</table>
</body>
</html>
The design (although not the code) was inspired by the JByte template engine
Constructor Summary | |
TemplateEngine()
|
Method Summary | |
void |
addValueProvider(ValueProvider p)
Add a value provider to the set of value providers |
Reader |
filter(Reader in)
Apply the template to a document. |
void |
removeValueProvider(ValueProvider p)
Remove a value provider from the list of value providers. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TemplateEngine()
Method Detail |
public Reader filter(Reader in)
in
- The Reader from which the document will be read.
public void addValueProvider(ValueProvider p)
p
- The ValueProvider to addpublic void removeValueProvider(ValueProvider p)
p
- The value provider to remove.
|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |