Created
June 16, 2012 18:06
-
-
Save rowanmanning/2942116 to your computer and use it in GitHub Desktop.
LESS Hackery
This file contains hidden or 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
// Allows specifying default variables in LESS | |
// Some really sneaky shit that will shoot me in the foot if | |
// LESS changes too much... | |
@--lol: ~`"" + ( root._less = root._less || this )`; | |
@--lol: ~`"" + ( root.getLessVar = function (name) { return root._less[name] ? root._less[name].toJS() : '' } )`; | |
@--lol: ~`"" + ( root.getLessVarDefault = function (name, def) { return root.getLessVar(name) !== '' ? root.getLessVar(name) : root.getLessVar(def) } )`; | |
// Example: | |
// | |
// If we were to set the variable `@override-variable` here, then `@variable` | |
// would be set to that value instead. | |
// | |
@default-variable: 1200px; | |
@variable: ~`root.getLessVarDefault('override-variable', 'default-variable')`; | |
// There are problems with this approach, but they relate to problems with | |
// calculation. See https://github.com/cloudhead/less.js/issues/816 for | |
// more info. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment