Notch Templates
Overview
Notch's built-in template engine
NotchTemplates is a template engine that composes chisel and the Notch expression parser to render text with embedded expressions and commands. Use it when you want a string-output template that can call into Notch evaluation.
A template file is made of three kinds of content:
- Literal text - copied to output verbatim.
- Expressions - the form
${ expression }evaluatesexpressionas Notch and substitutes the result. - Commands - a line beginning with
#invokes a template command (control flow, layout, macros, etc.).
The engine lives in the package edu.montana.notch.templates. The main entry points are:
NotchTemplates.TOKENIZER- a preconfigured chiselTokenizerfor template source.NotchTemplateRegistry- loads and caches templates; renders them to output.NotchTemplateLoader- the interface for plugging in a source of template files. Two implementations ship:NotchTemplateClasspathLoaderandNotchTemplateFilesystemLoader.NotchTemplateCommand- the base class for template commands. Subclass and register to add your own.
See also
- Getting Started for a worked load-and-render example.
- Template Syntax for the markers in detail.
- Built-in Commands for the 16 commands shipped out of the box.
- Custom Commands for adding your own.