The Diet template language is aimed at providing a way to define
procedurally generated HTML/XML pages (or other output formats), with
minimal visual noise. Syntax and feature set are heavily inspired by
and statements are D statements, and everything that can be done at
compile-time is done at compile-time.
Vibe.d still contains the original implementation, which was written
around the limitations of DMD's CTFE engine back years ago, and is
basically a monolithic parser+generator with little flexibility and a
number of convenience features missing, because of their implementation
complexity. The new implementation has been rewritten cleanly, with
separate parser, modifier and generator modules, working on a common DOM
tree intermediate representation.
The major new features/improvements are:
- No external dependencies other than Phobos
- Supports inline and nested tags syntax
- Supports string interpolations within filter nodes (falls back to
- Supports AngularJS special attribute names
- Extensible/configurable with traits structures
- Uses less memory during compilation (this one was a real surprise)
- (Unit) tested from the start
- Supports arbitrary uses other than generating HTML, for example we
use it similar to QML/XAML for our internal UI framework
The API documentation can be shown ba running DUB:
dub fetch diet-ng --version=1.0.0-alpha.2
dub run diet-ng -b ddox
You can try the library directly, or together with the latest alpha
release of vibe.d (0.7.30-alpha.3). Simply add a dependency to
"diet-ng", version "~>1.0.0-alpha.2". Vibe.d will automatically re-route
render!(...) calls to diet-ng.
A small example with just the most essential features is shown in the
More complex real-world examples:
Any comments/requests regarding the feature set or API are highly welcome!