expjs
Simple utility to expand string token with given rules
Install
npm install expjs
Usage
// the global mapping rule filevar Expander = ; var mappingRule = 'btn': 'fg-color-dark bg-color-light' 'btn-reverse': 'fg-color-light bg-color-dark'moduleexports = mappingRule; // a component file:var cm = ; var Btn = React;
The above reactjs code will yield component looks like
My buttn
Input variants (supported since v0.0.5)
In the above example, you pass the str list in a string separated by white space cm('btn-reverse other-class')
, expjs also allows you to pass in array or javascript arguments:
<button className=>My button</button><button className=>My button</button>
This will be useful when you are using variables for class name as shown above.