更新时间:2023-10-26 11:48:58
你几乎已经完成了它,然而胡须模板也可以被编译。 >
小胡子缺少帮手和更高级的方块,因为它试图无逻辑。 Handlebars的自定义助手可能非常有用,但通常最终会在您的模板中引入逻辑。
Mustache有许多不同的编译器(JavaScript,Ruby,Python,C等)。 )。 Handlebars以JavaScript开始,现在有像 django-handlebars ,handlebars.java , handlebars-ruby , lightncandy(PHP)和 handlebars-objc 。
Major differences I've seen are:
#if
, #unless
, #with
, and #each
{{this}}
in blocks (which outputs the current item's string value)Handlebars.SafeString()
(and maybe some other methods)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.