-
Notifications
You must be signed in to change notification settings - Fork 108
Home
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 the Go text/template template language, and the main diferences are, that we support template inheritance, simple C like expressions,pipelines can be used only in actions ex:{{expre|pipe|pipe}}, and all templates are file based, there is no "define","template" and "with" actions.
How to use:
- Create a Set and specify the lookup directories
- Call load template with the template name, the template will be loaded and cached, templates are loaded as they are need, ex: if your template extends, import or include an other template when loading your template those templates will be also loaded.
- Call to load template return the loaded template or a cached template you use this function to get templates by name when needed.
- You have the template you only need to invoke template execute with an writer, passing a var map and the context.
- Done!
Templates can extends a template and import blocks from another and every thing just works, in that way you can create a template library, layout templates and the application templates extending a layout and importing blocks like menu, buttons from library template.
The engine was design to be fast and light we can do that by avoid 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 in than way you can know exactly what is wrong.
In Jet you can extends, import and include templates.
- When extends all blocks from the template that you extends will be available for you even the ones that he import or extends, and when you extends a template when you execute the template the root of the extended template is used as the entry point
- When import a template all blocks of the imported template will be available in your template.
- When include the template is invoked all blocks available in your template will be available in the include template.