Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 318
GxXc Avatar asked Feb 19 '12 09:02

GxXc


1 Answers

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

like image 110
bobthecow Avatar answered Nov 06 '22 08:11

bobthecow