Render contents of input files through a templating engine (powered by consolidate.js)
First, install gulp-layoutize
as a development dependency:
npm install --save-dev gulp-layoutize
Then, add it to your gulpfile.js
:
var layoutize = require("gulp-layoutize");
gulp.src("./src/*.ext")
.pipe(layoutize({
templatePath: 'path/to/template',
engine: 'templatingEngine',
locals: {}
}))
.pipe(gulp.dest("./dist"));
Either define options.templatePath
or options.template
. If both are given, options.templatePath
is used.
Type: String
Default: undefined
Required: true
Path to template.
Type: String
Default: undefined
Required: true
Template content.
Type: String
Default: undefined
Required: true
Provide the templating engine name as supported by consolidate.js
.
Type: Object
Default: {}
Required: true
The locals object is passed as template variables to the templating engine. Refer to the templating engine guides on how to use variables in the template. Also, you have some predefined locals, refering to the current file:
- content (String): content of the current file
- file (Object): vinyl file object with filename, path, etc.