gulp-dotjs-convert
v1.0.1
Published
Compile dotjs template
Downloads
3
Maintainers
Readme
amdefine
A dotjs template can be converted to amd, CJS, es6, CMD standard module of the tool
Install
npm install gulp-dotjs-convert --save-dev
Usage
const dotjsConvert = require('gulp-dotjs-convert');
gulp.task("dotjs-convert", function(cb) {
return gulp.src(['src/**/*.tpl'])
.pipe(dotjsConvert({
type: 'cmd'
}))
.pipe(gulp.dest('./src'));
});
example
1) dotjs template
<div>
my name is <$=it.name$>
</div>
2) convert after
// cmd
define(function(require, exports, module) {
module.exports = function anonymous(it) {
var out = '<div> my name is ' + (it.name) + '</div>';
return out;
}
});
//adm
define(["exports"], function(exports) {
exports = function anonymous(it) {
var out = '<div> my name is ' + (it.name) + '</div>';
return out;
}
});
//es6
export default function anonymous(it) {
var out = '<div> my name is ' + (it.name) + '</div>';
return out;
}
//cjs
module.exports = function anonymous(it) {
var out = '<div> my name is ' + (it.name) + '</div>';
return out;
}
License
New BSD and MIT. Check the LICENSE file for all the details.