|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.templating.html.StringTemplate
A utility class to make it easier to read Java code that generates HTML.
Constructor Summary | |
StringTemplate(String htmlFragment)
Constructs a template. |
Method Summary | |
void |
bind(int i)
A conveniece method for binding int values. |
void |
bind(Object object)
|
void |
bind(String value)
Binds the next available placeholder that has not been bound yet. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public StringTemplate(String htmlFragment)
htmlFragment
- a string like "<h1>Java is $ times better
than Perl.</h1>"
, where the $ sign is a place holder for a
variable that can be bound via the bind(Object)
method.
Known bug: a run of multiple
dollar signs as in "foo$$$bar"
is treated as a single
placeholder, i.e., it is equivalent to "foo$bar"
.
Method Detail |
public void bind(String value)
To continue the example introduced in the constructor
, after doing something like this
StringTemplate html = new StringTemplate("<h1>Java is $ times better than Perl</h1>"); html.bind("5");
html.toString()
will evaluate to "<h1>Java is 5
times better than Perl</h1>"
.
public void bind(Object object)
public void bind(int i)
int
values.
bind(String)
public String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |