OSWS Templates gulp plugin 0.0.11
For osws-templates@0.2.5.
Usage
template.js
var Templates = require('osws-templates');
with(Templates.with) {
module.exports = div()('<%= name? name : "undefined" %>')
}
gulpfile.js
var gulp = require('gulp');
var templates = require('gulp-osws-templates');
gulp.task('templates', function() {
gulp.src('./template.js')
.pipe(templates({
context: { name: 'OSWS' }
}))
.pipe(gulp.dest('./'));
});
<div>OSWS</div>
Options
context
{ [name: string]: Templates.IContext };
arguments
Array;
handler
(template: Function, options: IOptions, file: GulpFile, callback: (result: string) => void)
Handle any file.
template.js
var Templates = require('osws-templates');
with(Templates.with) {
module.exports = div()('<%= name? name : "undefined" %>')
}
gulpfile.js
var gulp = require('gulp');
var templates = require('gulp-osws-templates');
gulp.task('templates', function() {
gulp.src('./template.js')
.pipe(templates({
context: { name: 'OSWS' },
arguments: [1, 2, 3],
// default handler
handler: function(template, options, file, callback) {
Templates.Module(template)
.apply(null, options.arguments)
.render(options.context, function(result) {
callback(result);
})
}
}))
.pipe(gulp.dest('./'));
});