Created
October 17, 2013 07:51
-
-
Save emilkaiser/7020813 to your computer and use it in GitHub Desktop.
Custom javascript function in less
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
/** | |
* node less-custom.js | |
* --> .class{width:2;height:olleh} | |
*/ | |
var less = require('less.js/lib/less'); | |
less.tree.functions.reverse = function (args) { | |
return new(less.tree.Anonymous)(new(less.tree.Anonymous)(args.value.split("").reverse().join(""))); | |
} | |
var parser = new(less.Parser)(); | |
parser.parse('.class { width: (1 + 1); height: reverse("hello") }', function (e, tree) { | |
var css = tree.toCSS({ compress: true }); // Minify CSS output | |
console.log(css); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment