mirror of
https://github.com/less/less.js.git
synced 2026-01-22 05:37:56 -05:00
Adding gsub function
This commit is contained in:
@@ -213,6 +213,13 @@ tree.functions = {
|
||||
escape: function (str) {
|
||||
return new(tree.Anonymous)(encodeURI(str.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B").replace(/\(/g, "%28").replace(/\)/g, "%29"));
|
||||
},
|
||||
gsub: function (str, regexp, replacement) {
|
||||
var str = str.value;
|
||||
|
||||
str = str.replace(new RegExp(regexp.value, "g"), replacement.value);
|
||||
|
||||
return new(tree.Quoted)('"' + str + '"', str)
|
||||
},
|
||||
'%': function (quoted /* arg, arg, ...*/) {
|
||||
var args = Array.prototype.slice.call(arguments, 1),
|
||||
str = quoted.value;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
}
|
||||
#built-in {
|
||||
escaped: -Some::weird(#thing, y);
|
||||
gsub: "Hello, World!";
|
||||
lighten: #ffcccc;
|
||||
darken: #330000;
|
||||
saturate: #203c31;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#built-in {
|
||||
@r: 32;
|
||||
escaped: e("-Some::weird(#thing, y)");
|
||||
gsub: gsub("Hello, Foo.", "Foo\.$", "World!");
|
||||
lighten: lighten(#ff0000, 40%);
|
||||
darken: darken(#ff0000, 40%);
|
||||
saturate: saturate(#29332f, 20%);
|
||||
|
||||
Reference in New Issue
Block a user