sprockets-dotjs 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
function encodeHTMLSource() {
|
2
2
|
var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' },
|
3
3
|
matchHTML = /&(?!#?\w+;)|<|>|"|'|\//g;
|
4
4
|
return function() {
|
5
5
|
return this ? this.replace(matchHTML, function(m) {return encodeHTMLRules[m] || m;}) : this;
|
6
6
|
};
|
7
|
-
}
|
7
|
+
}
|
8
|
+
String.prototype.encodeHTML = encodeHTMLSource();
|
@@ -17,10 +17,10 @@ module Sprockets
|
|
17
17
|
dotjs_lib = open(::File.join(::File.dirname(__FILE__), '..', '..', 'support', 'doT.js')).read
|
18
18
|
@@context = ::V8::Context.new
|
19
19
|
@@context.eval(dotjs_lib)
|
20
|
-
@@context['def'] = {}
|
21
20
|
end
|
22
21
|
|
23
22
|
def render(scope=Object.new, locals={}, &block)
|
23
|
+
@@context['def'] = {}
|
24
24
|
scope._dependency_paths.each {|a|
|
25
25
|
@@context['doT']['compile'].call(open(a).read,@@context['def'])
|
26
26
|
}
|
data/lib/support/doT.js
CHANGED
@@ -54,13 +54,15 @@
|
|
54
54
|
if (code.indexOf('def.') === 0) {
|
55
55
|
code = code.substring(4);
|
56
56
|
}
|
57
|
-
if (
|
58
|
-
if (
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
57
|
+
if (!(code in def)) {
|
58
|
+
if (assign === ':') {
|
59
|
+
if (c.defineParams) value.replace(c.defineParams, function(m, param, v) {
|
60
|
+
def[code] = {arg: param, text: v};
|
61
|
+
});
|
62
|
+
if (!(code in def)) def[code]= value;
|
63
|
+
} else {
|
64
|
+
new Function("def", "def['"+code+"']=" + value)(def);
|
65
|
+
}
|
64
66
|
}
|
65
67
|
return '';
|
66
68
|
})
|