Liquid Template Engine for Brick.js, implemented with [sirlantis/liquid-node][sirlantis/liquid-node].
Installation
npm install -S brick-liquid
Set template engine for brick.js
var brickJs = ;var Liquid = ; var brk = ; var liquid = ; brk; // set liquid engine for .liquid file brk; // set liquid engine for .html file app;
Include Modules(Partials)
In Brick.js, partials are organized as modules,
Sub-modules are imported by include
. For example:
{%include "user-list"%}
Above template will import module user-list
in root
directory with local context.
Layouts
Brick-liquid render is implemented asyncly to support template layout.
Module homepage
:
{%layout 'default'%} Hello!
Module default
:
{{title}} {% block %}
homepage
will be rendered and then replace {% block %}
declaration in default
.
In the meantime, the local context within homepage
will be passed into default
.
Options
cache
Type: Bool
Default: false
If set to true
, all templates will be loaded only once (for production usage). Otherwise, template file will be reloaded on every HTTP request.
Registration of New Filter
Brick-liquid is implemented with harttle/liquidjs internaly.
And the liquid
object defined above is compatible with harttle/liquidjs engine
object.
Javascript:
liquid;
Template:
{{ 'alice' | upper }}
Output:
ALICE
Registration of New Tag
Registration of new tag is compatible with harttle/liquidjs.
Javascript:
engine;
Template:
{% upper 'alice' %}
Output:
ALICE