I came across this ticket on github:
我在github上看到了这张票:
https://github.com/bobthecow/mustache.php/issues/34#issuecomment-805892
https://github.com/bobthecow/mustache.php/issues/34#issuecomment-805892
The comment states:
评论指出:
"Note that use of pragmas is not recommended, but they're there if you feel like you need 'em."
“请注意,建议不要使用pragma,但如果你觉得你需要它们,它们就在那里。”
I've never actually used Mustache but I am considering it for an upcoming project and I was wondering if its true that dot notation is bad practice for accessing array elements in Mustache. And if so, why?
我从来没有真正使用过Mustache,但是我正在考虑它即将推出的项目,我想知道点符号是否真的是在Mustache中访问数组元素的坏习惯。如果是这样,为什么?
1 个解决方案
#1
15
Let me try to give that a bit more context :)
让我试着给那个更多的背景:)
At the time that comment was written, Mustache (the templating language) did not support dot notation. It was, however, supported in several Mustache implementations (such as Mustache.php) as a pragma.
在撰写评论时,Mustache(模板语言)不支持点表示法。但是,它在几个Mustache实现(例如Mustache.php)中作为一个pragma支持。
Because it wasn't part of the spec, support wasn't guaranteed in all instances: it was a non-standard extension to Mustache. Hence the warning about not relying on pragmas.
因为它不是规范的一部分,所以在所有情况下都不能保证支持:它是Mustache的非标准扩展。因此警告不要依赖pragma。
Since that time, dot notation has been added to the spec, and it is now supported across all spec-compliant mustache implementations.
从那时起,dot符号已添加到规范中,现在支持所有符合规范的mustache实现。
So yes, by all means, use dot notation. It is a beautiful thing :)
所以,无论如何,请使用点符号。这是一件很美的事:)
#1
15
Let me try to give that a bit more context :)
让我试着给那个更多的背景:)
At the time that comment was written, Mustache (the templating language) did not support dot notation. It was, however, supported in several Mustache implementations (such as Mustache.php) as a pragma.
在撰写评论时,Mustache(模板语言)不支持点表示法。但是,它在几个Mustache实现(例如Mustache.php)中作为一个pragma支持。
Because it wasn't part of the spec, support wasn't guaranteed in all instances: it was a non-standard extension to Mustache. Hence the warning about not relying on pragmas.
因为它不是规范的一部分,所以在所有情况下都不能保证支持:它是Mustache的非标准扩展。因此警告不要依赖pragma。
Since that time, dot notation has been added to the spec, and it is now supported across all spec-compliant mustache implementations.
从那时起,dot符号已添加到规范中,现在支持所有符合规范的mustache实现。
So yes, by all means, use dot notation. It is a beautiful thing :)
所以,无论如何,请使用点符号。这是一件很美的事:)