wiki:WikiStart

Jabhts is a template system which:

  1. Uses 100% clean html/xhtml without any special tags or attributes. You can even add mock-up data so you can preview the final design in the browser/html-editor without any need to run it through the template processor first.
  2. Uses java annotations to specify the dynamic parts of the html templates: which elements have their content generated by java, which elements are loops (e.g. table rows).
  3. Has unique support for (a) scoping loops (e.g. table rows) by supporting inner-classes and Iterator/Iterable?, (b) specifying sub-attribute values such as css class names and style attributes. It doesn't just append text to the attribute value, but parses the content so you can suppress class names and css provided by the template.

Examples

Template:
<div class='_Box UserInfo' style='margin: 0; color: blue;'>
     You're logged in as
     <span id=PersonFullName>John Doe</span>
     (<a id=_Username>jdoe</a>).</div>
Output:
<div class=UserInfo 
     style='margin: 0; color: red; border: 1px solid black'>
     You're logged in as
     <span id=PersonFullName>Elliott Smith</span>
      (<a href='/info?user=es'>es</a>).</div>

The java code is all that it takes to implement the dynamic parts of the
template. There is no additional specification.
You would of course need to implement the full servlet interface.

Note: id attributes (and class names) which has a leading underscore
is automatically suppressed in the output by the template engine.

See the 30 second introduction for more info and more examples.

Minimal servlet:
public class DesignTest1 {
    @EHtml
    void printPersonFullName() {
        pw.print("Elliott Smith"); 
    }

    @EText
    String username = "es";

    @AHref
    String linkUsername() {
        return "/info?user=es";
    }

    @SValue(styles = "color")
    String clrBox() {
       return "red";
    }

    @SValue(styles = "border")
    String clrBox() {
       return "1px solid black";
    }
}

Documentation

JavaDoc for nightly build.

Getting the source and binaries

The latest nightly build: jar and the source as tar.gz or zip. The current source is available from the svn repository at http://jabhts.org/svn/trunk

XHTML templates are read using java's builtin xml parser. HTML templates are read using the python version of html5lib (how-to install). The java version is still too buggy, but as soon as it is usable, Jabhts will switch to it.

History

The initial version of Jabhts was created by Peter Speck as a project at Roskilde University. The project report is available at Roskilde University Digital Archive. Even when considering the changes made to Jabhts since the initial version, the project report is still worth reading as it documents the design decisions behind the system. It too describes the high-level design of the compiler, so it is a good introduction to the internals when you want to poke in its internals.

Trac documentation?

Last modified 7 years ago Last modified on 08/27/07 19:16:59