com.arsdigita.templating.html
Class StringTemplate

java.lang.Object
  extended bycom.arsdigita.templating.html.StringTemplate

public class StringTemplate
extends Object

A utility class to make it easier to read Java code that generates HTML.

Since:
2002-08-26
Version:
$Id: //core-platform/dev/src/com/arsdigita/templating/html/StringTemplate.java#4 $
Author:
Vadim Nasardinov (vadimn@redhat.com)

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

StringTemplate

public StringTemplate(String htmlFragment)
Constructs a template.

Parameters:
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

bind

public void bind(String value)
Binds the next available placeholder that has not been bound yet.

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>".


bind

public void bind(Object object)

bind

public void bind(int i)
A conveniece method for binding int values.

See Also:
bind(String)

toString

public String toString()


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC