TypeError applying precompiled Handlebars templates with a context

空扰寡人 提交于 2019-11-28 23:09:19

Be sure to match the versions of the Handlebars server and client packages. A way to check the version of the compiled template is the following:

handlebars a_template_of_yours.handlebars | grep "compilerInfo"

It should output something like this:

this.compilerInfo = [4,'>= 1.0.0'];

The first value is the Compiler Revision, which should match the output of the following code on your browser:

Handlebars.COMPILER_REVISION

If you used npm to download your Handlebars compiler, specify the version which you need. Here is an example for handlebars.runtime-v1.3.0.js:

npm install handlebars@1.3.0 -g

The problem for me is that currently (June 2014), the 2.0 release on GitHub is marked alpha https://github.com/wycats/handlebars.js/releases.

If I install handlebars via bower, it selects the latest stable release. v1.3.0.

npm install handlebars, however, installs the ~2.0.0-alpha.4 version.

Solution: update the version in bower.json to ~2.0.*, and run bower update.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!