js_render 0.3.0 → 0.4.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: 931cdb27a1564cea7a6719b853ae02809767e3e1
4
- data.tar.gz: 9c312aa181cc85b811fb42d1e5413c08031fe8c8
3
+ metadata.gz: 3537448b722ff236b75da2d4f60f5c69fbfa6290
4
+ data.tar.gz: 177de4414b1c645c485fbc6ef1b3bebe5b4a968f
5
5
  SHA512:
6
- metadata.gz: d0130b87cc4372619a790c24a53ba05905208a53e6faaa684e2e5b5828579064b8152176b08cd1e1c6ab791c52e6a1b968cd93e3b9cb660c6d1d774c97fbf2f2
7
- data.tar.gz: 9d902e9d87c9a78fd2d834b572ed17f49b5c96024878af06aa36344d4b2b45189f58b18d23db93483a7fd68690ec0a4dbecd07b1bbbe92d69fa00a67269e4d0c
6
+ metadata.gz: 97646f57c0c1428117e0ca0d2bb849f0cf04d6c5cdff34a3fd0f03cdb225f3668ff528b309b7ede336ec335493a7c377e61f46f6f2f651acac2ca89a5f6f14b3
7
+ data.tar.gz: 6869b116f9fdeb9842164f57727ad5878752f67da1e90976e7ca76c85e669c54f67dea3430b304d8c5231d13c3f699c8d50ff2c0aca478f49e2fe3ddb943f312
data/README.md CHANGED
@@ -3,8 +3,6 @@
3
3
 
4
4
  # JsRender
5
5
 
6
- **Disclaimer: This is currently a "work in progress". More functionality, improvements, and docs are coming. That said everything does work, but the API might change in the near future. Check out the docs below as well as the [`examples`](./examples).**
7
-
8
6
  JsRender is an unopinionated Ruby library for rendering JavaScript "components" on the server side. This approach works with [React](https://facebook.github.io/react/), [Angular](ihttps://angular.io/), [Ember](http://emberjs.com/), or any other library of your choice. The only requirement is that there is a JavaScript function that returns HTML for the component or view such that it can be properly rendered on the server side (e.g. [`ReactDOMServer.renderToString`](https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring) in React).
9
7
 
10
8
  The library works in two essential parts:
@@ -152,6 +150,12 @@ Methods you can override if you subclass `JsRender::AssetFinder::Base`:
152
150
 
153
151
  > Defaults to `nil`
154
152
 
153
+ ** should_server_render **
154
+
155
+ This config option is a boolean that specifies if the server render function and associated JS should be executed and run. When it is false, it only returns the span with the unique ID that the client side render function relies upon. This is meant for development purposes and enables things like console logging etc. that would normally cause errors in the `ExecJS` runtime.
156
+
157
+ > Defaults to `true`
158
+
155
159
  ## Development
156
160
 
157
161
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -22,7 +22,8 @@ module JsRender
22
22
  :server_render_function,
23
23
  :client_render_function,
24
24
  :use_asset_pipeline,
25
- :asset_finder_class
25
+ :asset_finder_class,
26
+ :should_server_render
26
27
 
27
28
  def initialize
28
29
  @base_path = 'app/assets/javascripts'
@@ -32,6 +33,7 @@ module JsRender
32
33
  @client_render_function = 'window.render*Client'
33
34
  @use_asset_pipeline = false
34
35
  @asset_finder_class = nil
36
+ @should_server_render = true
35
37
  end
36
38
  end
37
39
  end
@@ -26,6 +26,8 @@ module JsRender
26
26
  end
27
27
 
28
28
  def generate_html
29
+ return "<span id=\"#{@uuid}\"></span>" unless JsRender.config.should_server_render
30
+
29
31
  func_name = JsRender.config.server_render_function.gsub('*', @component_name)
30
32
  server_code = <<-JS
31
33
  (function () {
@@ -1,3 +1,3 @@
1
1
  module JsRender
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.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.3.0
4
+ version: 0.4.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: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2016-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler