Templating

A component's template is HTML plus dynamic tags. Bindings on the tags connect to the component's Java class.

<p>Hello <wo:str value="$name" />!</p>
public class Hello extends NGComponent {

	public String name = "world";

	public Hello( NGContext context ) {
		super( context );
	}
}

Template files

In src/main/resources/components, named after the class:

  • Hello.html, or
  • Hello.wo/Hello.html (plus an optional Hello.wod)

No subfolders. A template without a class works too.

Dynamic tags

<wo:tagName binding1="$someKey" binding2="Some constant" />
  • Always close the tag: </wo:tagName>, or />.
  • The tag name is a short name (str), a simple class name (NGString, Hello) or a fully qualified one.

All built-in elements: Dynamic elements.

Binding values

ValueMeaning
$name, $user.nameKey or keypath, resolved with KeyValueCoding
Some textConstant string. Escapes: \n \r \t \\ \" \$
$true, $falseBoolean constants
$42, $1.5Integer and Double constants
(no value) <wo:link disabled>true
$^nameThe value the parent bound to this component's name binding

No WebObjects @ operators, and no binding twice on one tag.

Embedding components

<wo:Hello name="$user.firstName" />

A wrapper renders the content between its tags at <wo:content />:

<!-- Page.html -->
<body>
	<header>My site</header>
	<wo:content />
</body>
<wo:Page>
	<p>Inside the body, below the header.</p>
</wo:Page>

WOD files

Supported, for templates coming from WebObjects:

<webobject name="Greeting" />
Greeting : NGString {
	value = name;
}

Quoted values are constants, unquoted ones keypaths. Use engifer's element names (NGString or str), not WOString.

Directives

  • <p:raw>…</p:raw>: output as is, no dynamic tags.
  • <p:comment>…</p:comment>: left out of the output.