sprockets-dotjs 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,8 @@
1
- String.prototype.encodeHTML=function encodeHTMLSource() {
1
+ function encodeHTMLSource() {
2
2
  var encodeHTMLRules = { "&": "&#38;", "<": "&#60;", ">": "&#62;", '"': '&#34;', "'": '&#39;', "/": '&#47;' },
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();
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Dotjs
3
- VERSION = "2.0.2"
3
+ VERSION = "2.0.3"
4
4
  end
5
5
  end
@@ -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 (assign === ':') {
58
- if (c.defineParams) value.replace(c.defineParams, function(m, param, v) {
59
- def[code] = {arg: param, text: v};
60
- });
61
- if (!(code in def)) def[code]= value;
62
- } else {
63
- new Function("def", "def['"+code+"']=" + value)(def);
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
  })
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-dotjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: