sugar-template
A simple template engine based on
mustache.js
.
Install
Usage
const sugar = sugar // --> 'TEST'sugar// --> Mike 18 M
Syntax
-
Expression,
{{varialbe}}
, starts with{{
and ends with}}
. -
HTML escaping. Normal expression will be automatically escaped. So, use
{{{varialbe}}}
if you don't wanna escaping. -
Helpers. Almost like
handlebars
,{{#helper context}} {{/helper}}
. -
Inline helpers.
{{helper context}}
. -
Filters.
{{context | filter}}
. -
Ignore Compile.
{{=text=}}
,text
here will output without any change.
API
sugar.render(String: template, Object: data)
Render template to string.
sugar.parse(String: template)
Parse template to AST.
License
MIT