Open shirohana opened 4 years ago
Merging #122 into master will increase coverage by
0.97%
. The diff coverage is90.90%
.
@@ Coverage Diff @@
## master #122 +/- ##
==========================================
+ Coverage 87.14% 88.12% +0.97%
==========================================
Files 21 21
Lines 459 480 +21
Branches 112 112
==========================================
+ Hits 400 423 +23
+ Misses 53 51 -2
Partials 6 6
Impacted Files | Coverage Δ | |
---|---|---|
src/context.js | 88.46% <ø> (ø) |
|
src/index.js | 100.00% <ø> (ø) |
|
src/visitors/Tag.js | 94.82% <90.00%> (+6.30%) |
:arrow_up: |
src/utils/get-class-name-value.js | 91.07% <91.07%> (+0.44%) |
: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 0cb224b...d8ef7b9. Read the comment docs.
Any response (´・ω・`)?
This is brilliant. Good job!
I made a new option to solve https://github.com/pugjs/babel-plugin-transform-react-pug/issues/111, this option grant everyone can decide which syntax to use between:
and
But before that, I must implement expressional className so I can make
attributeAlias
works correctly.This pull request brings two features in actual:
attributeAlias
className
Usage
babel.config.js
With
attributeAlias: { class: 'className' }
set, you can now write expressions insideclass
again just like the native syntax of Pug:Changes
1. Allow expression and array
*Pug allows pass array as class attribute natively.
All renders to: (ignore there's extra spaces in A and B)
2. Correct syntax of
className
*Also see: https://github.com/facebook/react/issues/3138
Before:
After:
3. ClassName interpolation
4. Default alias (❗Breaking Change)
Now we don't parse there attributes in initiative:
for
=>htmlFor
maxlength
=>maxLength
To make it works like before, create aliases in your babelrc:
babel.config.js
5. Limitation
Currently array spread operators are ignored, here's some sample:
More about
attributeAlias
With this option, you can even do more than just classNames.
For example, you can create shorthands like that:
babel.config.js
And feel the power: