它是不好的做法,使用点符号在胡子(PHP)? [英] Is it bad practice to use dot notation in Mustache (php)?

查看:88
本文介绍了它是不好的做法,使用点符号在胡子(PHP)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到这个票就在GitHub上:

I came across this ticket on github:

<一个href=\"https://github.com/bobthecow/mustache.php/issues/34#issuecomment-805892\">https://github.com/bobthecow/mustache.php/issues/34#issuecomment-805892

注释状态:

请注意,使用编译指示不推荐,但如果你觉得你需要'时间他们的存在。

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

推荐答案

让我尽量给更多的一些背景:)

Let me try to give that a bit more context :)

目前该意见被写入的时间,小胡子(该模板语言)不支持点表示法。它,然而,支持在几个胡子实现(如Mustache.php)作为杂。

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 :)

这篇关于它是不好的做法,使用点符号在胡子(PHP)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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