0.0.2 • Published 9 years ago

gulp-compile-template-requirejs v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
9 years ago

gulp-compile-template-requirejs

Compile Underscore templates.

Synopsis

Compile tpl file into a js file, ready for use with requirejs

Install

Install with npm

npm install --save-dev gulp-compile-template-requirejs

Example

gulpfile.js

var gulp = require('gulp');
var template = require('gulp-compile-template-requirejs');

gulp.task('default', function () {
	gulp.src('src/*.tpl')
		.pipe(template())
		.pipe(gulp.dest('dist'));
});

header.tpl

<h1>Hello World</h1>

header.js

define('path/header', function () { return function(obj){
var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};
with(obj||{}){
__p+='<h1>Hello World</h1>\n';
}
return __p;
}; });

view.js

define(['marionette', 'path/header'], function (Marionette, HeaderTemplate) {
    "use strict";
    var HeaderView = Marionette.LayoutView.extend({
        template: HeaderTemplate
    });
});