Last active
December 18, 2015 10:39
-
-
Save msweeney/5770059 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(str) { | |
return function(style) { | |
style.rules = style.rules.map(function(rule) { | |
if (rule.declarations) { | |
rule.declarations.forEach(function(decl, i) { | |
var token; | |
if (decl.comment) { | |
token = decl.comment.trim(); | |
if (token.charAt(0) === '$') { | |
rule.declarations[i+1].value = token; | |
} | |
} | |
}); | |
} | |
return rule; | |
}); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rework = require('..'), | |
addVars = require('addVars.js'), | |
read = require('fs').readFileSync; | |
var css = rework(read('button-skin.css', 'utf8')) | |
.use(addVars()) | |
.toString() | |
console.log(css); | |
/* yields: | |
(note comments removed for brevity) | |
.pure-button { | |
background-color: $buttonBackgroundColor; | |
border: $buttonBorderHex; | |
border: $buttonBorderRGBA; | |
border-radius: $buttonBorderRadius; | |
color: $buttonColorHex; | |
color: $buttonColorRGBA; | |
*color: $buttonColorHex; | |
padding: $buttonPadding; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment