mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
the e() LESS function
used to escape strings in values. Added Anonymous node to handle things like this.
This commit is contained in:
2
index.js
2
index.js
@@ -40,7 +40,7 @@ var less = {
|
||||
'keyword', 'variable', 'ruleset', 'element',
|
||||
'selector', 'quoted', 'expression', 'rule',
|
||||
'call', 'url', 'alpha', 'import',
|
||||
'mixin', 'comment'
|
||||
'mixin', 'comment', 'anonymous'
|
||||
].forEach(function (n) {
|
||||
require(path.join('less', 'tree', n));
|
||||
});
|
||||
|
||||
@@ -28,6 +28,9 @@ tree.functions = {
|
||||
else if (h * 3 < 2) return m1 + (m2 - m1) * (2/3 - h) * 6;
|
||||
else return m1;
|
||||
}
|
||||
},
|
||||
e: function (str) {
|
||||
return new(tree.Anonymous)(str);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
11
lib/less/tree/anonymous.js
Normal file
11
lib/less/tree/anonymous.js
Normal file
@@ -0,0 +1,11 @@
|
||||
if (typeof(require) !== 'undefined') { var tree = require('less/tree') }
|
||||
|
||||
tree.Anonymous = function Anonymous(string) {
|
||||
this.value = string.content;
|
||||
};
|
||||
tree.Anonymous.prototype = {
|
||||
toCSS: function () {
|
||||
return this.value;
|
||||
},
|
||||
eval: function () { return this }
|
||||
};
|
||||
@@ -4,3 +4,6 @@
|
||||
height: undefined("self");
|
||||
border-width: 5;
|
||||
}
|
||||
#built-in {
|
||||
escaped: -Some::weird(#thing, y);
|
||||
}
|
||||
|
||||
@@ -4,3 +4,7 @@
|
||||
height: undefined("self");
|
||||
border-width: add(2, 3);
|
||||
}
|
||||
|
||||
#built-in {
|
||||
escaped: e("-Some::weird(#thing, y)");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user