js_render 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44e4ca7607fdaa47edeb79eaa87ab02f4830b5c2
4
- data.tar.gz: a8579d5be73c8c6935403a8ea28c6f4411269271
3
+ metadata.gz: 3be557c75bf3ac9289edaa385ce18588477fe569
4
+ data.tar.gz: 44a2bdfa9e97fd9f2062d796bc47d5d6d9a5fbc1
5
5
  SHA512:
6
- metadata.gz: 6fdcd63206923591551212e3d0207f25d5d7cad3f8e24e14ac4844bf0271130e2aed72e819af42af0649568eb7b85f4b04ad9378744a6849b02692a7d60a0fc8
7
- data.tar.gz: 6e03a1600adcf4669b3697449feed57f5849c1849d37a879d93cda900b2ca615aa49a5bf5768fc7aeab4ae3f20109cfda96a9c50d3016b397e1e7a13543c4d03
6
+ metadata.gz: 472d3e54f85ecb729a8bf6cee4ea2abf3478d1218703ce3c49dfe730bc6372b874ed114665ac5e3fc9131ad8d497ab7d099c54e30ede412165cd449e119382fd
7
+ data.tar.gz: 8cbc98e3bdc1199d2f782e8dea4f0512aecae06150c50c76e21c0844123d92a4c7ed0d79f4218b7e5304df54a2c2f3634783ff11e48848cd4534fd15133dff31
data/README.md CHANGED
@@ -101,7 +101,7 @@ This is the base path where your components live.
101
101
 
102
102
  **component_paths**
103
103
 
104
- These are the paths off of your base path that are searched to find your component (or more accurately your components' server render functions). Wildcards are supported.
104
+ These are the paths off of your base path that are searched to find your component (or more accurately your components' server render functions). Wildcards are supported.
105
105
  If you are using Rails AND the asset pipeline, the lookup path can point to your pre-built file and the asset pipeline will give JsRender the built file. If you are using another build tool, make sure you are pointing to the built assets. JsRender will NOT take care of any compile step for you, it expects these files to already be compiled to ES5 compatible with [ExecJS](https://github.com/rails/execjs).
106
106
 
107
107
  > Defaults to `['/**/*']`
@@ -0,0 +1,5 @@
1
+ ['error', 'log', 'info', 'warn'].forEach(function (fn) {
2
+ console[fn] = function () {
3
+ console.history.push({level: fn, arguments: Array.prototype.slice.call(arguments)});
4
+ };
5
+ });
@@ -0,0 +1,19 @@
1
+ (function(history) {
2
+ var result = '';
3
+ if (history && history.length > 0) {
4
+ result += '\n<script class="js_render-console-replay">';
5
+ history.forEach(function (msg) {
6
+ var filteredArgs = msg.arguments.map(function(arg) {
7
+ try {
8
+ JSON.stringify(arg);
9
+ return arg;
10
+ } catch(e) {
11
+ return null;
12
+ }
13
+ });
14
+ result += '\nconsole.' + msg.level + '.apply(console, ' + JSON.stringify(filteredArgs) + ');';
15
+ });
16
+ result += '\n</script>';
17
+ }
18
+ return result;
19
+ })(console.history)
@@ -12,8 +12,12 @@ module JsRender
12
12
  var global = global || this;
13
13
  var self = self || this;
14
14
  var window = window || this;
15
+ var console = console || { history: [] };
15
16
  JS
16
17
 
18
+ CONSOLE_POLYFILL = File.read(File.join(File.dirname(__FILE__), 'polyfills', 'console_polyfill.js'))
19
+ CONSOLE_REPLAY = File.read(File.join(File.dirname(__FILE__), 'polyfills', 'console_replay.js'))
20
+
17
21
  def initialize(component_name, data)
18
22
  @component_name = component_name
19
23
  unless data.is_a?(String)
@@ -38,7 +42,8 @@ module JsRender
38
42
  server_code = <<-JS
39
43
  (function () {
40
44
  var serverStr = typeof #{func_name} === 'function' ? #{func_name}(#{@json_data}) : '';
41
- return '<span id="#{@uuid}">' + serverStr + '</span>';
45
+ var consoleReplayStr = #{CONSOLE_REPLAY};
46
+ return '<span id="#{@uuid}">' + serverStr + '</span>' + consoleReplayStr;
42
47
  })()
43
48
  JS
44
49
  context.eval(server_code)
@@ -64,7 +69,7 @@ module JsRender
64
69
  suffix = JsRender.config.component_suffix
65
70
  @@cache.getset(base_path + paths.join('') + suffix + @component_name) do
66
71
  renderer_code = asset_finder.read_files(@component_name)
67
- ExecJS.compile(GLOBAL_CONTEXT + renderer_code)
72
+ ExecJS.compile(GLOBAL_CONTEXT + CONSOLE_POLYFILL + renderer_code)
68
73
  end
69
74
  end
70
75
 
@@ -1,3 +1,3 @@
1
1
  module JsRender
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js_render
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Lehman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-24 00:00:00.000000000 Z
11
+ date: 2018-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -228,6 +228,8 @@ files:
228
228
  - lib/js_render/asset_finder/base.rb
229
229
  - lib/js_render/configuration.rb
230
230
  - lib/js_render/errors.rb
231
+ - lib/js_render/polyfills/console_polyfill.js
232
+ - lib/js_render/polyfills/console_replay.js
231
233
  - lib/js_render/rails.rb
232
234
  - lib/js_render/rails/asset_finder.rb
233
235
  - lib/js_render/rails/railtie.rb