|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.jtpl.Jtpl
public class Jtpl
Jtpl: a very simple template engine for Java
Contact: emmanuel.alliel@gmail.com
Web: http://jtpl.sourceforge.net
Template syntax:
Variables:
{VARIABLE_NAME}
Blocks:
<!-- BEGIN: BlockName -->
<!-- BEGIN: SubBlockName -->
<!-- END: SubBlockName -->
<!-- END: BlockName -->
License: Apache 2.0
Constructor Summary | |
---|---|
Jtpl(File file)
Constructs a Jtpl object and reads the template from a file. |
|
Jtpl(Reader template)
Constructs a Jtpl object and reads the template from arbitrary input source. |
|
Jtpl(String fileName)
Constructs a Jtpl object and reads the template from a file. |
Method Summary | |
---|---|
void |
assign(String varName,
String varData)
Assign a template variable. |
protected String |
escape(String replacement)
Template parsing uses regex replace to insert result text, which means that special characters in replacement string must be escaped. |
protected Set |
locateBlock(String blockName)
Lists the blocks that end with the given blockName. |
String |
out()
Generates the HTML page and return it into a String. |
void |
parse(String blockName)
Parse a template block. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Jtpl(String fileName) throws IOException
fileName
- the file name
of the template, exemple: "java/folder/index.tpl"
IOException
- when an i/o error occurs while reading the template.public Jtpl(File file) throws IOException
file
- readable file containing template source
IOException
- when an i/o error occurs while reading the template.public Jtpl(Reader template) throws IOException
template
- the template source
IOException
- when an i/o error occurs while reading the template.Method Detail |
---|
public void assign(String varName, String varData)
parse
is called.
varName
- the name of the variable to be set.varData
- the new value of the variable.public String out()
public void parse(String blockName) throws IllegalArgumentException
blockName
- the name of the block to be parsed.
IllegalArgumentException
- if the block name is not found (and failSiletly==false)protected String escape(String replacement)
replacement
- The text that should appear in output.
protected Set locateBlock(String blockName)
blockName
- The name as used in parse
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |