Last active
August 29, 2015 14:20
-
-
Save rjgotten/36427563bda8428fb9d2 to your computer and use it in GitHub Desktop.
Emit literal content with Less plugin functions and detached rulesets
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
function Literal( text ) { | |
this.text = text; | |
} | |
Literal.prototype = new tree.Node(); | |
Literal.prototype.constructor = Literal; | |
Literal.prototype.type = "Literal"; | |
Literal.prototype.accept = function ( visitor ) {}; | |
Literal.prototype.eval = function ( context ) { | |
return new Literal( this.text ); | |
}; | |
Literal.prototype.genCSS = function ( context, output ) { | |
output.add( this.text ); | |
}; | |
functions.add( "literal", function( text ) { | |
var literal, ruleset; | |
literal = new Literal( String( text.value )); | |
ruleset = new tree.Ruleset( null, [ literal ]); | |
return new tree.DetachedRuleset( ruleset, []); | |
}); |
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
.link { | |
@plugin "literal.js"; | |
@literal : literal( "@define-placeholder item-link {};" ); | |
@literal(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment