Skip to content

Latest commit

 

History

History
executable file
·
82 lines (63 loc) · 1.91 KB

readme.md

File metadata and controls

executable file
·
82 lines (63 loc) · 1.91 KB

OSWS Templates gulp plugin 0.3.0

gulp-osws-templates

GitHub version npm version Build Status

For oswst@0.3.0.

Usage

template.js

var T = require('oswst');

with(T.with) {
    module.exports = div()('<%= name? name : "undefined" %>')
}

gulpfile.js

var gulp = require('gulp');
var oswst = require('gulp-oswst');

gulp.task('templates', function() {
    gulp.src('./template.js')
    .pipe(oswst({
        context: { name: 'OSWS' }
    }))
    .pipe(gulp.dest('./'));
});
<div>OSWS</div>

TOptions

context

{ [name: string]: TContext };

arguments

Array;

handler

(template: Function, options: TOptions, file: GulpFile, callback: (result: string) => void)

Handle any file.

template.js

var T = require('oswst');

with(T.with) {
    module.exports = div()('<%= name? name : "undefined" %>')
}

gulpfile.js

var gulp = require('gulp');
var oswst = require('gulp-oswst');

gulp.task('templates', function() {
    gulp.src('./template.js')
    .pipe(oswst({
        context: { name: 'OSWS' },
        arguments: [1, 2, 3],
        
        // default handler
        handler: function(template, options, file, callback) {
    		Templates.Module(template)
    		.apply(null, options.arguments)
    		.render(callback, options.context);
        }
    }))
    .pipe(gulp.dest('./'));
});