pugjs / pug

Pug – robust, elegant, feature rich template engine for Node.js
https://pugjs.org
21.54k stars 1.96k forks source link

Make attributes parenthesis optional #3393

Closed brauliobo closed 1 year ago

brauliobo commented 1 year ago

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?

webdiscus commented 1 year ago

@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?

meatsdd commented 1 year ago

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

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

brauliobo commented 1 year ago

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