admin管理员组文章数量:1406003
I'm trying to build a Handlebars app using only JavaScript. I've noticed in there documentation, they initialize using:
var source = $("#entry-template").html();
Is this step required or is there a way around it using only native Javascript?
I'm trying to build a Handlebars app using only JavaScript. I've noticed in there documentation, they initialize using:
var source = $("#entry-template").html();
Is this step required or is there a way around it using only native Javascript?
Share Improve this question asked Jun 20, 2015 at 4:04 Trey HuffineTrey Huffine 2423 silver badges9 bronze badges 1-
document.getElementById('entry-template').innerHTML
? – Ry- ♦ Commented Jun 20, 2015 at 4:11
2 Answers
Reset to default 5No, it doesn't require jQuery.
Only reason why people prefer jQuery is because of ease of use with which jQuery perform various operations. It saves lots of time & additional effort.
Using handlebars with plain javscript will require some extra effort. If you have enough time then you should try out things with plain JavaScript.
Below given links might be of some help to understand things better -
http://code.tutsplus./tutorials/handlebarsjs-a-behind-the-scenes-look--net-32678
http://www.raymondcamden./2012/04/19/Demo-of-Handlebars-and-why-you-should-consider-a-templating-engine
No. If you read the example further you would see they are only using jQuery to get the HTML content of an element. This is something that could have been done in vanilla JS. Any code that follows is not jQuery. The following is the same example sans jQuery. As you can see the way Handlebars is written is unaffected.
var source = document.getElementById("entry-template").innerHTML;
var template = Handlebars.pile(source);
本文标签: javascriptDoes Handlebars require jQueryStack Overflow
版权声明:本文标题:javascript - Does Handlebars require jQuery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744959868a2634586.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论