Skip to content

OSWS/gulp-oswst

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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