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 +4 -4
- data/README.md +1 -1
- data/lib/js_render/polyfills/console_polyfill.js +5 -0
- data/lib/js_render/polyfills/console_replay.js +19 -0
- data/lib/js_render/renderer.rb +7 -2
- data/lib/js_render/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3be557c75bf3ac9289edaa385ce18588477fe569
|
4
|
+
data.tar.gz: 44a2bdfa9e97fd9f2062d796bc47d5d6d9a5fbc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,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)
|
data/lib/js_render/renderer.rb
CHANGED
@@ -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
|
-
|
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
|
|
data/lib/js_render/version.rb
CHANGED
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.
|
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-
|
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
|