gulp-tpl2amd
1.0.1 • Public • Published gulp-tpl2amd
Convert js templates to AMD modules no matter what syntax
Install
$ npm install --save-dev gulp-tpl2amd
Usage
▸ bower_components/
▾ js/
▸ myapp/
▾ tpl/ # generated by gulp-tpl2amd
header.js
app.js
▸ vendor/
main.js
▸ scss/
▾ tpl/
▾ myapp/
header.tpl
gulpfile.js
gulpfile.js
var gulp = require('gulp');
var tpl2amd = require('gulp-tpl2amd');
gulp.task('build:tpl', ['clean:tpl'], function() {
gulp.src('tpl/myapp/**/*.tpl')
.pipe(tpl2amd())
.pipe(gulp.dest('js/myapp/tpl'));
});
js/myapp/app.js
define(['tpl/header'], function(tpl_header){
console.log(tpl_header.template);
});
tpl/myapp/header.tpl
<div class="header">
<h1>{%= title %}</h1>
</div>
js/myapp/tpl/header.js
define([], function(){
return {"template":"\n<div class=\"header\">\n <h1>{%= title %}</h1>\n</div>\n"};
});
License
MIT © dexteryy
Versions
Version | Downloads (Last 7 Days) | Tag |
---|
1.0.1 | 0 | latest |
Version History
Version | Downloads (Last 7 Days) | Published |
---|
1.0.1 | 0 | |
Package Sidebar
Install
Weekly Downloads