Rendr アプリのコンパイラとして gulp を使用しようとしていますが、次の問題が発生しています。
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
コンパイルとgulp を使用した例がどこにも見つからなかったので、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タスクは次のことを行います。
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 をインストールしようとしましたが、運が悪かったので、助けていただければ幸いです。