improve keyword and anonymous input for replace (and %)

This commit is contained in:
seven-phases-max
2014-11-25 04:04:50 +04:00
parent 7d97027222
commit ccd49bb619
3 changed files with 31 additions and 1 deletions

View File

@@ -3,7 +3,7 @@ var Node = require("./node"),
Variable = require("./variable");
var Quoted = function (str, content, escaped, index, currentFileInfo) {
this.escaped = escaped;
this.escaped = (escaped == null) ? true : escaped;
this.value = content || '';
this.quote = str.charAt(0);
this.index = index;

View File

@@ -161,3 +161,15 @@
extract: 3 2 1 C B A;
length: 6;
}
#quoted-functions-in-mixin {
replace-double-quoted: 'foo-2';
replace-single-quoted: 'foo-4';
replace-escaped-string: bar-2;
replace-keyword: baz-2;
replace-anonymous: qux-2;
format-double-quoted: "hello world";
format-single-quoted: 'hello single world';
format-escaped-string: hello escaped world;
format-keyword: hello;
format-anonymous: hello anonymous world;
}

View File

@@ -176,3 +176,21 @@
extract: extract(@anon, 6) extract(@anon, 5) extract(@anon, 4) extract(@anon, 3) extract(@anon, 2) extract(@anon, 1);
length: length(@anon);
}
#quoted-functions-in-mixin {
// Quoted type may have some weird side-effects when used in mixins (#2308)
.mixin();
.mixin() {
replace-double-quoted: replace('foo-1', "1", "2");
replace-single-quoted: replace('foo-3', "3", "4");
replace-escaped-string: replace(~"bar-1", "1", "2");
replace-keyword: replace(baz-1, "1", "2");
replace-anonymous: replace(e("qux-1"), "1", "2");
format-double-quoted: %("hello %s", "world");
format-single-quoted: %('hello %s', "single world");
format-escaped-string: %(~"hello %s", "escaped world");
format-keyword: %(hello);
format-anonymous: %(e("hello %s"), "anonymous world");
}
}