pugjs / babel-plugin-transform-react-pug

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

How do you handle variables in a single quotation? #99

Closed pruge closed 5 years ago

pruge commented 5 years ago

I am performing the following example. https://nextjs.org/learn/basics/create-dynamic-pages/adding-a-list-of-posts

I am having trouble changing the following syntax:

const PostLink = props => (
  <li>
    <Link href={`/post?title=${props.title}`}>
      <a>{props.title}</a>
    </Link>
  </li>
)

Even if I try this, it is not applied.

const PostLink = props => pug`
  li
    Link(href='/post?title=${props.title}')
      a #{props.title}
`

How do I fix this?

Link(href='/post?title=${props.title}')
// .babelrc
{
  "plugins": [
    "transform-react-pug",
    "transform-react-jsx",
    [
      "transform-jsx-classname-components",
      {
        "objects": [
          "React"
        ]
      }
    ]
  ]
}
ForbesLindesay commented 5 years ago
Link(href='/post?title=' + props.title)
pruge commented 5 years ago

Thank you very much.