Something like:
btn = ({click, text})->
a.pug.btn(target='blank' on-click=click) #{text}
Notice that coding using the PUG framework is much easier and more readable than thr HTML codes. PUG makes use of indentation to distinguish between where a tag starts and ends. This makes the code much cleaner than HTML, where lack of indentation and a need for closing tags makes the code a little cluttered.
Pugs are known for being sociable and gentle companion dogs. The American Kennel Club describes the breed's personality as "even-tempered and charming". Pugs remain popular into the twenty-first century, with some famous celebrity owners.
I see this question is quite old, but if you are still looking for the answer, then there is an official plugin for babel, which transpiles pug into jsx: https://github.com/pugjs/babel-plugin-transform-react-pug
For example:
export default const ReactComponent = props => pug`
.wrapper
if props.shouldShowGreeting
p.greeting Hello World!
button(onClick=props.notify) Click Me
`
Will provide similar to this:
export default const ReactComponent = props => (
<div className="wrapper">
{props.shouldShowGreeting && (
<p className="greeting">Hello World</p>
)}
<button onClick={props.notify}>Click Me</button>
</div>
)
There are more examples in repository.
You can use pug-as-jsx : https://github.com/bluewings/pug-as-jsx-loader
You will find steps to do it here : can i use pug (ex-jade) with react framework?
A blog about this : https://medium.com/nishantsblog/pug-templates-for-react-presentation-components-7610967954a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With