Skip to content

OSWS/gulp-oswst

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Feb 25, 2015
1331ba4 · Feb 25, 2015

History

32 Commits
Feb 23, 2015
Feb 23, 2015
Feb 23, 2015
Feb 23, 2015
Feb 23, 2015
Feb 23, 2015
Feb 25, 2015
Feb 20, 2015
Feb 25, 2015

Repository files navigation

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('./'));
});