Advanced template engine for Java

View project onGitHub

Stencil is a delightful template language with a concise syntax and advanced capabilities. It is written in Java and has an easy and advanced API that makes integrating it into any environment a breeze.


Stencil uses '$' to begin dynamic outputs and ';' to end them. It allows you to quickly define macros and functions right inside your template. Layouts, even extremely advanced ones, are supported by using the same simple and elegant block passing syntax that is used with macros. Even whole templates files can be used as macros or layouts. To wrap it all up nicely Stencil is built around a simple expression language that can be used in any of its contexts.

Stencil also features a rich API that allows advanced control of loading, caching and makes extending the engine easy. It even has some really nifty features like Extension Methods that save a lot of time when writing templates.


$$import ''

 * Use our layout macro from ''

$layout('My Page')
	header {
	content {
		Glad you stopped by this page!

 * Define a simple layout macro
$macro layout(title) [header, content, footer] {
	<div class="content">
		$footer {
			© Copyrright 2003