cssobj-plugin-replace
cssobj plugin to replace object key/value pair with new value (Object, Array, Function etc.)
Install
- npm
npm i cssobj-plugin-replace
Then
var cssobj = var cssobj_plugin_replace = // result:p color: blue;
Quick Start
Replace simple value:
Replace color red
with blue
// { p:{color:'red'} } => p {color: blue;}
Replace value with array:
// { p:{font:123} } => p { font:1; font:2; font:3; }
Replace value with object:
// { p:{font:'heading'} } => p { font-family: Arial; font-size: 24px; font-weight: bold; }
Replace value with array of object:
// { p:{display:'flex'} } => p { display: -webkit-flex; display: flex; }
Replace any key/value:
Use null as placeholder for any key/value matched.
null as value to match any value
// { p:{display:1} } => p { display: -webkit-flex; display: flex; }
null as key to match any key
// { p:{color:'red'} } => p { display: -webkit-flex; display: flex; }
Replace with function
newValue can be function to dynamic calc the replacement.
// { p:{padding:1, margin:0} } => p { padding: 1px; margin:0; }
Requirement
cssobj version >= 0.5.2
License
MIT