[ This announcement is off-topic here and will be the only one of its
  kind.  The reason I'm posting it is that I believe it might be of
  some interest to the readers of this list.  Please direct all
  responses not related to Perl's HTML::Template to me personally.
  Thanks! ]

If you like HTML::Template's syntax and API, but must program in Java,
you might want to try htmltemplate:

    http://fly.srk.fer.hr/~hniksic/htmltemplate-0.9.tar.gz

It implements the template syntax of HTML::Template and most of the
features of that module.  The API is somewhat adjusted to Java where
it's not as easy to create lists and hashes /ad hoc/, but the "spirit"
is the same.  For example, instantiating the template looks like this:

    Template tmpl = new Template(fileName);
    Params p = new Params();
    p.set("variableName", "variableValue");
    ...
    Params.Loop loop = p.makeLoop("loopName");
    for (...) {
        Params row = loop.makeRow();
        row.set("variableValue", "variableValue");
        ...
    }
    tmpl.param(p);
    System.out.print(tmpl.output());  // or tmpl.output(WRITER)

Htmltemplate tries to keep the rendering process as efficient as
possible.  You can obtain a "compiled template" object and reuse it to
process the same template again, at a tremendous performance gain.
Transparent caching of templates is supported: when turned on,
htmltemplate caches the compiled objects and return the one from the
cache next time you ask for the same template file.  With caching, I
get the rendering speed of ~3000 templates per second on a 1GHz
Pentium under JVM 1.4.0.  The cache is thread-safe, but carefully
synchronized to avoid lock contention.

Features not present in HTML::Template: the support for multipart
templates using the TMPL_BOUNDARY tag (idea borrowed from Tomas
Styblo's Python implementation); the support for an optional NAMESPACE
attribute to TMPL_INCLUDE to stuff all the include variables in their
own namespace so as to avoid naming pollution; the support for
TMPL_MASTER and TMPL_SLAVE tags for advanced inclusion.  (I will
elaborate on this in a separate mail, not specific to my package.)

HTML::Template features not present here: {shared,file}_cache: I felt
that these were not too needed in Java where it's usually a given that
you run in a multi-threaded environment.  search_path_on_include:
always true and currently untogglable.  *_debug: don't have that.
associate: unclear how well this translates to Java.

The package is currently licensed under the terms of the GNU GPL.  If
enough people convince me that they would use the package but for the
license, I might consider a less restrictive (BSD-style) license.


NOTE: this is a different package from Philip Tellis's HTML.Template.
I had somewhat different (and quite specific) goals in mind when
writing this one, so I implemented it from the ground up.  If you
don't like the idea of an alternative Java implementation, please feel
free to ignore it, or at least flame me privately.  :-)


-------------------------------------------------------
This sf.net email is sponsored by: Influence the future 
of Java(TM) technology. Join the Java Community 
Process(SM) (JCP(SM)) program now. 
http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0002en

_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to