1.2.0 • Published 7 years ago

@buxlabs/gulp-ejs-to-jst v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

gulp plugin that converts ejs to jst

Installation

npm install @buxlabs/gulp-ejs-to-jst

Idea

The plugins converts ejs templates into functions. It can be useful if you want to compile your templates server side for better performance. The plugin returns a raw unnamed function so you should convert it further and e.g. wrap with cjs / amd or any other format of your choice.

Usage

Convert files with:

const gulp = require('gulp');
const converter = require('@buxlabs/gulp-ejs-to-jst');

module.exports = function (options) {
    return gulp.src(options.src)
    .pipe(converter())
    .pipe(gulp.dest(options.dest));
};

Example:

ejs

<div>hello world</div>

jst

function(obj){var__t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};with(obj||{}){__p+='<div>helloworld</div>';}return__p;}