pugjs/pug

Make attributes parenthesis optional

brauliobo opened this issue · 3 comments

I've come from the Slim Template where attributes don't require to be inside parenthesis.

For me, it sounds really weird the parenthesis, as it seems like tags are function calls.

Is it possible to make attributes parenthesis optional?

@brauliobo

no it's impossible because Pug syntax not allow it and this can follow to confusion.

Correct Pug

p.teaser(data-tooltip="Teaser") Teaser text

Generated HTML

<p class="teaser" data-tooltip="Teaser">Teaser text</p>

If attribute parenthesis are omitted, then the attributes will be the text after the tag.

Your suggested Pug syntax

p.teaser data-tooltip="Teaser" Teaser text

Generated HTML

<p class="teaser">data-tooltip="Teaser" Teaser text</p>

How then to distinguish the text of the tag from attributes without parentheses?

How then to distinguish the text of the tag from attributes without parentheses?

Configuring prefixes like "data-" to be acknowledge as attributes, maybe?

I'm closing this for now as it is just about making it a bit prettier and it seems complicated to implement