ext-twig

Twig compiler with optional lhtml formatting.

Usage

rtb.twig(options={});

Options

options will override rtb.moduleOptions.

rtb.buildOptions (BuildConfig.buildOptions)

OptionTypeDefaultDescription
minifybooleanfalseMinify html output.
prettifybooleanfalsePrettify html output.

If both minify and prettify options are set, then minify is done first and then prettified.

rtb.moduleOptions (BuildConfig.moduleOptions)

PropertyTypeDefaultDescription
twigObject{}Options to gulp-twig. twig.data can be object or data file names in string or string array.
htmlminObject{}Options to gulp-htmlmin.
prettierObject{}Options to gulp-prettier.

if twig.data is Object type, then it is used as data for gulp-twig. If it is string or string[], then it is understood as data file names and loaded using gulp-data. Data file format supported are yaml and JSON. The extension names should be .yml or .yaml, or .json.

Example

const twig = {
name: 'twig',
builder: (rtb) => rtb.src().markdown().dest(),
src: ['assets/twig/*.twig')],
dest: 'www/'),
buildOptions: { prettify: true },
moduleOptions: {
twig: {
base: 'assets/twig'),
data: 'assets/data/**/*.{yaml,yml,json}',
extend: twigMarkdown,
functions:[
{
name: "nameOfFunction",
func: function (args) {
return "the function";
}
}
],
filters:[
{
name: "nameOfFilter",
func: function (args) {
return "the filter";
}
}
]
},
prettier: { useTabs: false, tabWidth: 4 },
htmlmin: { collapseWhitespace: true, }
},
};

Notes

This extension is for custom processing. Use GTwigBuilder for twig file processiing.