HTML.Template.java

HTML.Template version 0.1.2 - 9 October 2002

HTML.Template aims to do to java what HTML::Template.pm did to perl. HTML.Template makes it possible to use HTML Templates inside your java code. You no longer need to recompile your servlets everytime you change the HTML.

Your templates are normal HTML files with a few extra tags where variable content goes. The Template module replaces these tags with values specified through your program, and displays the combined document.

See the Howto for information and sample code to use templates in your java programs.

This package is intended to make it easy for a HTML designer to develop templates to be used in conjunction with your java code. Many a time the person developing the application, and the person designing the look aren't the same. The designer knows nothing about programming, and although as developers we'd like to think that we are good designers, the fact is that many of us aren't.

HTML.Template, like its perl counterpart, extends HTML with a few HTML like tags - <tmpl_var>, <tmpl_loop>, <tmpl_include>, <tmpl_if>, <tmpl_else> and <tmpl_unless>. The file written with HTML and these new tags is called a template. Using the HTML.Template class, you fill in the values for the variables, loops and branches declared in the template.

What differentiates HTML.Template from other templating solutions is that is enforces a strict distinction between logic and layout. A template cannot contain programming logic (except from the branches and loops).

A second point worth noting, is that using HTML.Template for java and HTML::Template for perl means that your templates are interoperable across two languages. 'The first cross-language templating standard', as Jesse Erlbaum would put it :).

Acknowledgements

Thanks go to Sam Tregar, the developer of the HTML::Template perl module, for writing that most excellent module that I use for everything, and for sticking firm to the principle of not allowing programming logic into templates.

I'd also like to thank Sam for allowing me to use the code examples from the perl module in the documentation for this module. Those familiar with the docs of HTML::Template will notice a lot in common in the overall documentation.

If you're planning of writing perl code that may require templates, have a look at Sam's Module. The link is on the left (at the top if your browser doesn't fully support stylesheets).

Thanks also to the chaps on the htmltmpl mailing list for keeping the discussions lively.

Copyright

This package is Copyright (c) 2002 Philip S Tellis (philip.tellis At gmail.com). Distribution is under the terms Artistic or GNU General Public Licence.

Licence

This module is free software; you can redistribute it and/or modify it under the terms of either:

  1. the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or
  2. the "Artistic License" which comes with this module.

You should have received a copy of the Artistic License with this module, in the file Artistic.txt. If not, I'll be glad to provide one.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Warranty

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the Artistic License for more details.