最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - mustache.js vs. jquery-tmpl - Stack Overflow

programmeradmin1浏览0评论

I'm looking at javascript templating for the first time and mustache and jquery-tmpl are the top contenders at the moment.

Some of my requirements:

  • templates will live in separate files to be included on multiple pages
  • all (or almost all) data will come from calls to a restful api which returns json
  • we're a java/eclipse shop, so syntax highlighting and compatibility with that would be nice, if it's an issue at all

Anyone know of any comparisons in terms of speed, ease of use, flexibility, stability? Any other factors I should be considering? Other top templating engines?

(I know there are other questions on this general topic, but I don't see any direct, broad comparisons between these two.)

I'm looking at javascript templating for the first time and mustache and jquery-tmpl are the top contenders at the moment.

Some of my requirements:

  • templates will live in separate files to be included on multiple pages
  • all (or almost all) data will come from calls to a restful api which returns json
  • we're a java/eclipse shop, so syntax highlighting and compatibility with that would be nice, if it's an issue at all

Anyone know of any comparisons in terms of speed, ease of use, flexibility, stability? Any other factors I should be considering? Other top templating engines?

(I know there are other questions on this general topic, but I don't see any direct, broad comparisons between these two.)

Share Improve this question edited May 23, 2017 at 12:06 CommunityBot 11 silver badge asked Dec 8, 2010 at 21:37 sprugmansprugman 19.8k36 gold badges115 silver badges164 bronze badges 2
  • 1 Which one did you finally choose? – lo5 Commented Mar 7, 2011 at 14:41
  • mustache. but I haven't fully implemented it yet -- other priorities got in the way. – sprugman Commented Mar 7, 2011 at 16:11
Add a comment  | 

2 Answers 2

Reset to default 15

My reason to choose mustache over any other template language was that it is implemented for any language you are likely to use. As it is also a true logic agnostic templating language your templates become portable. Therfore you gain the flexibility to choose to render your templates on the client or server side. Even though I have no benchmark available I don't think that performance should be an issue.

Initially I started out using jquery templates but development on that halted a long time ago.

Have a look at handlebar.js as an alternative to mustache.js ( see http://catchvar.com/jquery-tmpljs-vs-handlebarsjs )

handlebar.js seems to be about 2x faster than mustache. I've been using handlebar in a few projects and mustasche in one or two. I much prefer handlebar and find it 'better'. Here's a nice tutorial by Andrew Burgess I found.

Edit Mar-2013: Also since then Twitter have released Hogan.js which looks awesome like everything else that Twitter does, so I'll be investigating that too at some point.

发布评论

评论列表(0)

  1. 暂无评论