phug-php / phug

Phug - The Pug Template Engine for PHP
https://phug.selfbuild.fr
MIT License
62 stars 3 forks source link

.length parameter of array #25

Closed khades closed 6 years ago

khades commented 6 years ago

PugJS has ability to return length of array is you call "length" parameter, php-yii2, which uses phug does not use it. Will this feature be implemented?

kylekatarnls commented 6 years ago

Hi, it's possible to implement it but you should be aware that all your template is converted into PHP, no into JS. To get a 100% full-support of the JS engine (you loose PHP stuff inside your templates in counter part), then you can see our Alternatives section in the documentation: https://phug-lang.com/#alternatives

While I will think of the features and possible side effects, you can use the PHP count function:

p=count(myArray)
kylekatarnls commented 6 years ago

Hi, .length is now available on strings and arrays. You can use composer update to get this new feature.