phug-php / phug

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

Block expansion works wrong with inline text #42

Closed radiocity closed 5 years ago

radiocity commented 5 years ago

Hello,

I encountered an issue with the following code:

- var $pageTitle = "123"
a(href = "#" rel = "nofollow"): | !{$pageTitle}

I expected to get:

<a href="#" rel="nofollow">123</a>

But I actually get:

<a href="#" rel="nofollow"></a>123

Workaround:

- var $pageTitle = "123"
a(href = "#" rel = "nofollow") !{$pageTitle}

Thanks!

kylekatarnls commented 5 years ago

Hi, I don't understand this syntax:

a(href = "#" rel = "nofollow")!=$pageTitle

Would be quite enough to display unescaped text inside a tag.

Or in interpolation style:

a(href = "#" rel = "nofollow") !{$pageTitle}

Block expansion is not supposed to be for texts (as text doesn't need it to be on the same line), expansion is between 2 tags.

Thanks.

radiocity commented 5 years ago

IMHO, It doesn't matter if you do not understand syntax or its purpose. It should work as designed with no suprices.

kylekatarnls commented 5 years ago

In documentation we explain:

Block Expansion To save space, Phug provides an inline syntax for nested tags.

This means we guarantee the behavior for nested tags. Supporting more is a feature request.

Supporting extra verbosity in a language designed to shorten your template code and bring clarity via a lighter syntax is a nice-to-have.

If you may explain why my alternative does not suit, I will reconsider. Else, since any additional syntax support comes with a regression risk, development, maintenance, documentation efforts and performance cost, I can't implement every possible edge-case just because it can be used some day somewhere, I have to evaluate if benefits worth it.

Thanks for your understanding.

I'm still ready to re-open if there is something you can't achieve with != or !{}