pugjs / babel-plugin-transform-react-pug

A plugin for transpiling pug templates to jsx
MIT License
808 stars 46 forks source link

New option: "classAttribute" #62

Closed ezhlobo closed 5 years ago

ezhlobo commented 6 years ago

Now we convert .test, div(class="test") and div(className="test") into <div className="test" />.

This PR adds the possibility to specify any attribute you need instead of className in the result. For example:

{
  "plugins": [
    ["babel-plugin-transform-react-pug", {
      "classAttribute": "styleName"
    }]
  ]
}
pug`.test`

// =>

<div styleName="test" />

This is extremely useful for writing templates with CSS Modules more smoothly.

Initial request: #27

codecov-io commented 5 years ago

Codecov Report

Merging #62 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #62   +/-   ##
=======================================
  Coverage   82.24%   82.24%           
=======================================
  Files          20       20           
  Lines         445      445           
  Branches      103      103           
=======================================
  Hits          366      366           
  Misses         70       70           
  Partials        9        9
Impacted Files Coverage Δ
src/visitors/Tag.js 85.71% <100%> (-0.5%) :arrow_down:
src/context.js 88.46% <100%> (+0.22%) :arrow_up:
src/index.js 100% <100%> (ø) :arrow_up:
src/utils/parse.js 91.3% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 429ca31...a6a1000. Read the comment docs.