Skip to content

Instantly share code, notes, and snippets.

@rjgotten
Last active August 29, 2015 14:20
Show Gist options
  • Save rjgotten/36427563bda8428fb9d2 to your computer and use it in GitHub Desktop.
Save rjgotten/36427563bda8428fb9d2 to your computer and use it in GitHub Desktop.
Emit literal content with Less plugin functions and detached rulesets
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, []);
});
.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