admin管理员组文章数量:1024629
I prepiled my handlebars template like this:
handlebars tabs.hbs -f tabs.js
I load them like this:
<script type="text/javascript" src="js/handlebars.runtime.min.js"></script>
<script type="text/javascript" src="js/templates/tabs.js"></script>
<script type="text/javascript" src="js/tabsData.js"></script>
This is how I provide the context to the prepiled template:
var template=Handlebars.templates["tabs.hbs"];
var html=template(tabsData);
console.log(html)
sidebar.setContent(html);
I get this error:
Uncaught TypeError: undefined is not a function handlebars.runtime.js 436
/*Error points here*/
var result = templateSpec.call(
container,
namespace, context,
helpers,
partials,
options.data);
This is template
:
function (context, options) {
options = options || {};
var namespace = options.partial ? options : env,
helpers,
partials;
if (!options.partial) {
helpers = options.helpers;
partials = options.partials;
}
var result = templateSpec.call(
container,
namespace, context,
helpers,
partials,
options.data);
if (!options.partial) {
env.VM.checkRevision(containerpilerInfo);
}
return result;
}
I prepiled my handlebars template like this:
handlebars tabs.hbs -f tabs.js
I load them like this:
<script type="text/javascript" src="js/handlebars.runtime.min.js"></script>
<script type="text/javascript" src="js/templates/tabs.js"></script>
<script type="text/javascript" src="js/tabsData.js"></script>
This is how I provide the context to the prepiled template:
var template=Handlebars.templates["tabs.hbs"];
var html=template(tabsData);
console.log(html)
sidebar.setContent(html);
I get this error:
Uncaught TypeError: undefined is not a function handlebars.runtime.js 436
/*Error points here*/
var result = templateSpec.call(
container,
namespace, context,
helpers,
partials,
options.data);
This is template
:
function (context, options) {
options = options || {};
var namespace = options.partial ? options : env,
helpers,
partials;
if (!options.partial) {
helpers = options.helpers;
partials = options.partials;
}
var result = templateSpec.call(
container,
namespace, context,
helpers,
partials,
options.data);
if (!options.partial) {
env.VM.checkRevision(container.pilerInfo);
}
return result;
}
Share
Improve this question
edited Jul 9, 2014 at 14:30
vamsiampolu
asked Jul 8, 2014 at 17:45
vamsiampoluvamsiampolu
6,70420 gold badges90 silver badges194 bronze badges
5
- you'll need to figure out which item is undefined. – Mike Cheel Commented Jul 8, 2014 at 17:54
-
@MikeCheel Calling
template(tabsData)
throws thiserror
,I trying using the samecontext
and piling it ontryhandlebarsjs.
where it works. – vamsiampolu Commented Jul 9, 2014 at 4:54 - What do u get for console.log(template) – blessanm86 Commented Jul 9, 2014 at 12:49
-
@blessenm Added the
template
code... – vamsiampolu Commented Jul 9, 2014 at 14:31 - I think Handlebars.templates["tabs.hbs"] is returning undefined. Check if Handlebars.templates has ur template and if the key 'tabs.hbs' si correct. – blessanm86 Commented Jul 9, 2014 at 15:01
1 Answer
Reset to default 4As biomorgoth mented here: https://stackoverflow./a/22214119
Make sure your npm version corresponds to the client version. Client version is in the the top of the js file and you find npm version with:
npm list -g | grep handlebars
installing the 1.3.0 version with npm solved the issue for me.
sudo npm install -g [email protected]
I prepiled my handlebars template like this:
handlebars tabs.hbs -f tabs.js
I load them like this:
<script type="text/javascript" src="js/handlebars.runtime.min.js"></script>
<script type="text/javascript" src="js/templates/tabs.js"></script>
<script type="text/javascript" src="js/tabsData.js"></script>
This is how I provide the context to the prepiled template:
var template=Handlebars.templates["tabs.hbs"];
var html=template(tabsData);
console.log(html)
sidebar.setContent(html);
I get this error:
Uncaught TypeError: undefined is not a function handlebars.runtime.js 436
/*Error points here*/
var result = templateSpec.call(
container,
namespace, context,
helpers,
partials,
options.data);
This is template
:
function (context, options) {
options = options || {};
var namespace = options.partial ? options : env,
helpers,
partials;
if (!options.partial) {
helpers = options.helpers;
partials = options.partials;
}
var result = templateSpec.call(
container,
namespace, context,
helpers,
partials,
options.data);
if (!options.partial) {
env.VM.checkRevision(containerpilerInfo);
}
return result;
}
I prepiled my handlebars template like this:
handlebars tabs.hbs -f tabs.js
I load them like this:
<script type="text/javascript" src="js/handlebars.runtime.min.js"></script>
<script type="text/javascript" src="js/templates/tabs.js"></script>
<script type="text/javascript" src="js/tabsData.js"></script>
This is how I provide the context to the prepiled template:
var template=Handlebars.templates["tabs.hbs"];
var html=template(tabsData);
console.log(html)
sidebar.setContent(html);
I get this error:
Uncaught TypeError: undefined is not a function handlebars.runtime.js 436
/*Error points here*/
var result = templateSpec.call(
container,
namespace, context,
helpers,
partials,
options.data);
This is template
:
function (context, options) {
options = options || {};
var namespace = options.partial ? options : env,
helpers,
partials;
if (!options.partial) {
helpers = options.helpers;
partials = options.partials;
}
var result = templateSpec.call(
container,
namespace, context,
helpers,
partials,
options.data);
if (!options.partial) {
env.VM.checkRevision(container.pilerInfo);
}
return result;
}
Share
Improve this question
edited Jul 9, 2014 at 14:30
vamsiampolu
asked Jul 8, 2014 at 17:45
vamsiampoluvamsiampolu
6,70420 gold badges90 silver badges194 bronze badges
5
- you'll need to figure out which item is undefined. – Mike Cheel Commented Jul 8, 2014 at 17:54
-
@MikeCheel Calling
template(tabsData)
throws thiserror
,I trying using the samecontext
and piling it ontryhandlebarsjs.
where it works. – vamsiampolu Commented Jul 9, 2014 at 4:54 - What do u get for console.log(template) – blessanm86 Commented Jul 9, 2014 at 12:49
-
@blessenm Added the
template
code... – vamsiampolu Commented Jul 9, 2014 at 14:31 - I think Handlebars.templates["tabs.hbs"] is returning undefined. Check if Handlebars.templates has ur template and if the key 'tabs.hbs' si correct. – blessanm86 Commented Jul 9, 2014 at 15:01
1 Answer
Reset to default 4As biomorgoth mented here: https://stackoverflow./a/22214119
Make sure your npm version corresponds to the client version. Client version is in the the top of the js file and you find npm version with:
npm list -g | grep handlebars
installing the 1.3.0 version with npm solved the issue for me.
sudo npm install -g [email protected]
本文标签: javascriptPrecompiled handlebars template not workingStack Overflow
版权声明:本文标题:javascript - Precompiled handlebars template not working - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745617293a2159366.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论