在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):paulwib/gulp-hogan-compile开源软件地址(OpenSource Url):https://github.com/paulwib/gulp-hogan-compile开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-hogan-compileA gulp plugin to compile mustache HTML templates to JavaScript functions using hogan. UsageIn <p>Hello {{place}}</p> In your gulpfile: var compiler = require('gulp-hogan-compile');
gulp.task('templates', function() {
gulp.src('templates/**/*.html')
.pipe(compiler('templates.js'))
.pipe(gulp.dest('js/'));
}); In your code: var templates = require('js/templates.js');
var html = templates.test.render({
place: 'world';
})
console.log(html); // <p>Hello world</p> This will compile the templates into a JavaScript AMD module using It will Alternatively you can pass an object to have it populated with executable templates, which is useful if you need templates as part of a build step, for example: var compiler = require('gulp-hogan-compile');
var templates = {};
gulp.task('templates', function() {
gulp.src('templates/**/*.html')
.pipe(compiler(templates));
});
gulp.task('render', ['templates'], function() {
// Do something with templates, like passing to a static site generator
}); Parameters
Options
newLine |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论