Stencil

Advanced template engine for Java

View project onGitHub

Syntax

Stencil's syntax is designed to reduce typing as much as possible and to feel like the text and output commands are naturally woven together.

Overview

All text in a Stencil template is output without modification. Only outputs are processed by the template engine.

To begin a dynamic section you always use the '$' and to end it you always use the ';'.

		$myVal;
	

Different output commands can take "Blocks" of text. To define a block you wrap it in '{' and '}'.

		$if x {
			This text is in a block
		};
		
		$if y { This text is too }
	

Some commands, and user defined macros, can take more than one block.

		$if x {
			This text is in a block
		}
		else {
			A second block
		};
	

That's the basics!

You can read all the details about outputs, expressions, functions, macros, etc. using the syntax reference at the right.