-
Notifications
You must be signed in to change notification settings - Fork 110
Home
This is the documentation for Jet v2. You can find the documentation for v1 here.
v2's syntax is slightly different in a few places – read the upgrade to v2 guide.
- much more powerful
{{block}}
and{{yield}}
constructs, allowing local variables, default variables as well as wrapping (read more) - fast functions that are up to 50% faster than normal functions; the built-in
len
andisset
functions are implemented as fast functions (read more) - simple string concatenation in templates obviate the need for
sprintf
-like functions:{{ "build."+someString+".your-string" }}
(see here) -
isset
can now be used to check for the existence of a key in a map (works both with the var map as well as the context, see here) - templates can now also be imported/included relatively and without the extension; provided the templates' filenames end with
.jet
,.html.jet
or.jet.html
(read more)
Jet is a template engine that was designed to be easy to use and fast.
- simple and familiar syntax
- easy to use
- dynamic
- fast and light
- useful error messages
- template inheritance
- powerful
The syntax has many similarities with Go's text/template templating language. The main differences are:
- support for template inheritance
- simple C-like expressions
- pipelines can only be used in actions (i.e.
{{ expression|pipe|pipe }}
) - all templates are file based – there are no "define", "template" or "with" actions
Templates can extend a template (known as a layout) and import blocks from another and everything just works, that way you can create a template library, layout templates and the application templates.
The engine was designed to be fast and light by avoiding unnecessary allocations and a fast runtime.
All error messages are tied to the file and line of the node executing the action or expression, and all message are descriptive so you know exactly what's wrong.
In Jet you can extend, import and include templates:
- when extending, all blocks from the template that you extend will be available for your template even the ones that it imports or extends, also the root of the extended template is used as the entry point when executing
- when importing a template, all blocks of the imported template will be available in your template
- When including a template, the template will be invoked and all blocks available in your template will be available in the included template
Time to Get Started with Jet!