nette / latte

☕ Latte: the safest & truly intuitive templates for PHP. Engine for those who want the most secure PHP sites.
https://latte.nette.org
Other
1.09k stars 107 forks source link

Please add n:tag-syntax for better support of AlpineJS #366

Closed BernhardBaumrock closed 2 weeks ago

BernhardBaumrock commented 2 weeks ago

When using AlpineJS we often have to add markup like this to our tags:

<div x-data='{counter: 0}'>

This conflicts with latte markup if syntax is set to single braces, so I have to workaround like this:

https://fiddle.nette.org/latte/#632f86a638

{syntax double}
<div x-data='{counter: 0}'>
{/syntax}
    Your counter is <span x-text='counter'>{$counter}</span>
</div>

Of course I could also do this:

{syntax double}
<div x-data='{counter: 0}'>
    Your counter is <span x-text='counter'>{$counter}</span>
</div>
{/syntax}

But the content of the div might be a lot more complex in real world or even include other template files, so I really want to stick to single brackets if possible.

So what I'd love to have is this:

<div
    n:tag-syntax='double'
    x-data='{counter: 0}'
    title='{{$foo}}'
>
    Your counter is <span x-text='counter'>{$counter}</span>
</div>

Thx for considering!

mabar commented 2 weeks ago

You can also put space after { and before } in json. Latte will ignore it and the IDE should understand it well.

Doubled syntax is currently not supported by Latte plugin for PHPStorm and may take some time to implement it

BernhardBaumrock commented 2 weeks ago

Ah, nice, thank you! Adding quotes will also work: https://fiddle.nette.org/latte/#f5e4e9fff7

No need for n:tag-syntax then :)