Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I made a new option to solve #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: facebook/react#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: