fis3-parser-swig2
a plugin for fis3, use swig to enhance html.
Fis3-parser-swig2 can help us to use swig with fis3. We can use some awesome features in swig, like extends, SwigOpts.locals and so on. Fis3-parser-swig2 mainly solves the problem of resource location using swig with fis3.
You can see some examples below.
Installation
npm install --save-dev fis3-parser-swig2
Use
parser: fis;
options type(Object) Properties:
Name | Type | Description |
---|---|---|
autoescape | boolean | Controls whether or not variable output will automatically be escaped for safe HTML output. Defaults to true. Functions executed in variable statements will not be auto-escaped. Your application/functions should take care of their own auto-escaping. |
varControls | array | Open and close controls for variables. Defaults to ['{{', '}}']. |
tagControls | array | Open and close controls for tags. Defaults to ['{%', '%}']. |
cmtControls | array | Open and close controls for comments. Defaults to ['{#', '#}']. |
locals | object | Default variable context to be passed to all templates. |
Examples
/widgets/layout/layout.tpl
{% block title %}My Site{% endblock %} {% block head %} {% endblock %} {% block content %}{% endblock %}
widgets/index/index.tpl
{% extends '/widgets/layout/layout.tpl' %} {% block title %}My Page{% endblock %} {% block head %} {% parent %} {% endblock %} {% block content %}This is just an awesome page.{% endblock %}
fis-conf.js
fis; fis;
conf/index.js
moduleexports = pageUrl: './page/url';
result: widgets/index/index.html
My Page This is just an awesome page.