我正在尝试使用gulp作为我的rendr应用程序的编译器,但我遇到了
的问题500 TypeError: template is not a function
at module.exports.Backbone.View.extend.getInnerHtml (/home/longjeongs/thinksquareio.github.io/node_modules/rendr/shared/base/view.js:191:12)
at module.exports.Backbone.View.extend.getHtml (/home/longjeongs/thinksquareio.github.io/node_modules/rendr/shared/base/view.js:198:21)
at ViewEngine.getViewHtml (/home/longjeongs/thinksquareio.github.io/node_modules/rendr/server/viewEngine.js:75:15)
at ViewEngine.render (/home/longjeongs/thinksquareio.github.io/node_modules/rendr/server/viewEngine.js:22:16)
at View.render (/home/longjeongs/thinksquareio.github.io/node_modules/express/lib/view.js:126:8)
at tryRender (/home/longjeongs/thinksquareio.github.io/node_modules/express/lib/application.js:639:10)
at EventEmitter.render (/home/longjeongs/thinksquareio.github.io/node_modules/express/lib/application.js:591:3)
at ServerResponse.render (/home/longjeongs/thinksquareio.github.io/node_modules/express/lib/response.js:961:7)
at /home/longjeongs/thinksquareio.github.io/node_modules/rendr/server/router.js:87:11
at Object.module.exports.create (/home/longjeongs/thinksquareio.github.io/app/controllers/users_controller.js:5:5)
我找不到任何在任何地方编译rendr-handlebars
和handlebars
的示例,我想我会尝试在这里获得一些帮助。
我在其他地方读到这是由不同的编译器把手和客户端手柄版本引起的,但我相信我已经安装了正确的。我安装了这些依赖项
│ ├─┬ handlebars@2.0.0
├─┬ gulp-handlebars@3.0.1
├─┬ handlebars@2.0.0
├── rendr-handlebars@2.0.1
我的compiledTempaltes.js
文件显示"compiler":[6,">= 2.0.0-beta.1"]
。我的把手任务是做以下事情;
gulp.task('handlebars:compile', function () {
return gulp.src('./app/templates/**/[!__]*.hbs')
.pipe(plumber())
.pipe(handlebars({ wrapped : true, handlebars: require('handlebars') }))
.pipe(wrap('templates["<%= file.relative.replace(/\\\\/g, "/").replace(/.js$/, "") %>"] = <%= file.contents %>;\n'))
.pipe(concat('compiledTemplates.js'))
.pipe(wrap('module.exports = function(Handlebars){\ntemplates = {};\n<%= contents %>\nreturn templates \n};'))
.pipe(gulp.dest('app/templates/'));
});
我已经尝试过安装不同版本的车把,rendr-handlebars和gulp-handlebars而没有太多运气,我们将非常感谢任何帮助。
答案 0 :(得分:0)
我在我的rendr项目中使用gulp ...我制作了一个示例应用,你可以查看... https://github.com/jaredrada/rendrjs-demo
浏览器同步存在一些问题我已在本地修复 - 因此,如果您复制整个gulp设置,该部分将无效。我将把我的编辑推送到github repo。