Mustache.js和Handlebars.js有什么区别? [英] What are the differences between Mustache.js and Handlebars.js?

查看:173
本文介绍了Mustache.js和Handlebars.js有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





(请纠正我,如果我错了上述。)



有没有其他的m我缺少的主要区别是什么?

解决方案

你几乎已经完成了它,然而胡须模板也可以被编译。 >

小胡子缺少帮手和更高级的方块,因为它试图无逻辑。 Handlebars的自定义助手可能非常有用,但通常最终会在您的模板中引入逻辑。



Mustache有许多不同的编译器(JavaScript,Ruby,Python,C等)。 )。 Handlebars以JavaScript开始,现在有像 django-handlebars handlebars.java handlebars-ruby lightncandy(PHP) handlebars-objc

Major differences I've seen are:

  • Handlebars adds #if, #unless, #with, and #each
  • Handlebars adds helpers
  • Handlebars templates are compiled (Mustache can be too)
  • Handlebars supports paths
  • Allows use of {{this}} in blocks (which outputs the current item's string value)
  • Handlebars.SafeString() (and maybe some other methods)
  • Handlebars is 2 to 7 times faster
  • Mustache supports inverted sections (i.e. if !x ...)

(Please correct me if I'm wrong with the above.)

Are there any other major differences I am missing?

解决方案

You've pretty much nailed it, however Mustache templates can also be compiled.

Mustache is missing helpers and the more advanced blocks because it strives to be logicless. Handlebars' custom helpers can be very useful, but often end up introducing logic into your templates.

Mustache has many different compilers (JavaScript, Ruby, Python, C, etc.). Handlebars began in JavaScript, now there are projects like django-handlebars, handlebars.java, handlebars-ruby, lightncandy (PHP), and handlebars-objc.

这篇关于Mustache.js和Handlebars.js有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆