pugjs / babel-plugin-transform-react-pug

A plugin for transpiling pug templates to jsx
MIT License
810 stars 47 forks source link

prop spreading (support attribute blocks) #148

Closed p-98 closed 3 years ago

p-98 commented 3 years ago

I am trying to translate jsx with prop spreading to pug

<div {...attributes} />

The only possibility I was able to come up with was

div&attributes(attributes)

Unfortunately this currently throws Attribute blocks are not yet supported in react-pug.

It would be awesome to see this feature supported. Or is there any other solution?

ezhlobo commented 3 years ago

@p-98 hey, have you tried div(...attributes)?

It works different ways, you can play here: https://react.pugjs.org/repl#%7B%22code%22:%22ZXhwb3J0IGNvbnN0IFJlYWN0Q29tcG9uZW50ID0gcHJvcHMgPT4gcHVnYAogIGRpdiguLi5wcm9wcy5hdHR0cmlidXRlcykKICAKICBkaXYoLi4uYXR0cmlidXRlcykKYA==%22%7D

Screenshot 2021-11-19 at 18 21 09
p-98 commented 3 years ago

@ezhlobo thanks for the clue. Seems like I missed it.

Since this syntax makes attribute blocks obsolete, I will close this issue.