mirror of
https://github.com/less/less.js.git
synced 2026-01-23 14:18:00 -05:00
New % function, to perform string interpolation
This commit is contained in:
@@ -67,6 +67,16 @@ tree.functions = {
|
||||
},
|
||||
e: function (str) {
|
||||
return new(tree.Anonymous)(str);
|
||||
},
|
||||
'%': function (quoted /* arg, arg, ...*/) {
|
||||
var args = Array.prototype.slice.call(arguments, 1),
|
||||
str = quoted.content;
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
str = str.replace(/%[sd]/, args[i].toCSS());
|
||||
}
|
||||
str = str.replace(/%%/g, '%');
|
||||
return new(tree.Quoted)('"' + str + '"', str);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ less.Parser = function Parser(env) {
|
||||
call: function () {
|
||||
var name, args;
|
||||
|
||||
if (! (name = $(/([a-zA-Z0-9_-]+)\(/g))) return;
|
||||
if (! (name = $(/([a-zA-Z0-9_-]+|%)\(/g))) return;
|
||||
|
||||
if (name[1].toLowerCase() === 'alpha') { return $(this.alpha) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user