首先,我的最終目標是能夠使用jade
模板和backbone
但這是我能想到的最佳解決方案。如何使用Jadeify和Gulp
browserify.gulp
//appoligies for including it all.
gulp.task('browserify', function() {
var bundler = browserify({
// Required watchify args
cache: {}, packageCache: {}, fullPaths: true,
// Specify the entry point of your app
entries: ['./src/site/js/app.js'],
// Add file extentions to make optional in your requires
extensions: ['.js'],
// Enable source maps!
debug: true
});
var bundle = function() {
// Log when bundling starts
bundleLogger.start();
return bundler
.transform(require('jadeify'))
.bundle()
// Report compile errors
.on('error', handleErrors)
// Use vinyl-source-stream to make the
// stream gulp compatible. Specifiy the
// desired output filename here.
.pipe(source('main.js'))
// Specify the output destination
.pipe(gulp.dest('./public/js'))
// Log when bundling completes!
.on('end', bundleLogger.end);
};
if (global.isWatching) {
bundler = watchify(bundler);
// Rebundle with watchify on changes.
bundler.on('update', bundle);
}
return bundle();
});
Jade.gulp
gulp.task('jade', function() {
return gulp.src('./src/site/views/*.jade')
.on('error', handleErrors)
.pipe(jade())
.pipe(gulp.dest('public/views/templates'));
});
app.js
//the main angular file
var jamie = require("../views/resultsMini.jade");
console.info(jamie);
//outputs:
function template(locals) {
var buf = [];
var jade_mixins = {};
var jade_interp;
buf.push("<div>Results List</div>");;return buf.join("");
}
所以真正的quesiton是,爲什麼jamie
不能返回我的HTML?我想我只是做到了完全錯誤的:(
有一些使用我是缺少在這裏從文檔:現在https://github.com/domenic/jadeify
var template = require("./template.jade");
document.getElementById("my-thing").innerHTML = template({
localVar: "value",
anotherOne: "another value"
});
你可愛的勒沃爾男人!!!! '「browserify」:{ 「transform」:[ 「jadeify」 ] },'這對我有用 – 2015-02-08 05:34:59
是的變換可以通過package.json文件或通過JavaScript應用。像你一樣通過JavaScript來做是最好的方法。它允許更容易地添加選項,並避免與package.json文件混淆。我已經改變了我的吞嚥任務也是這樣。 – 2015-02-20 19:23:17