Is it bad practice to use dot notation in Mustache (php)?

风流意气都作罢 提交于 2019-12-05 22:33:31

问题


I came across this ticket on github:

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."

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?


回答1:


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.

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.

Since that time, dot notation has been added to the spec, and it is now supported across all spec-compliant mustache implementations.

So yes, by all means, use dot notation. It is a beautiful thing :)



来源:https://stackoverflow.com/questions/9347998/is-it-bad-practice-to-use-dot-notation-in-mustache-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!