먼저 궁극적 인 목표는 jade
템플릿을 backbone
과 함께 사용할 수있게하는 것입니다. 그러나 이것이 제가 생각해 낼 수있는 최상의 해결책입니다.Gulp에서 Jadeify를 사용하는 방법
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'));
});
그래서 진짜 후 질문입니다
//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("");
}
app.js, 왜 jamie
은 나에게 HTML을 돌려주지 않는가? ? https://github.com/domenic/jadeify
var template = require("./template.jade");
document.getElementById("my-thing").innerHTML = template({
localVar: "value",
anotherOne: "another value"
});
를 고정하지 않은 이상한 있지만
–예 변형은 package.json 파일이나 JavaScript를 통해 적용 할 수 있습니다. 당신이했던 것처럼 자바 스크립트를 통해 그것을하는 것이 최선의 방법입니다. 옵션을 더 쉽게 추가 할 수 있으며 package.json 파일을 사용하는 것을 피할 수 있습니다. 내 꿀꺽 꿀꺽 삼키는 일을 그렇게 바꿨습니다. –