render_execjs 0.0.2 → 0.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.
- data/README.md +28 -3
 - data/lib/generators/templates/render_execjs.rb +3 -14
 - data/lib/render_execjs/version.rb +1 -1
 - metadata +15 -15
 
    
        data/README.md
    CHANGED
    
    | 
         @@ -6,7 +6,7 @@ Render executable JavaScript within Rails. 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            Add `render_execjs` to your `Gemfile`
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                gem 'render_execjs', '~> 0.0. 
     | 
| 
      
 9 
     | 
    
         
            +
                gem 'render_execjs', '~> 0.0.2'
         
     | 
| 
       10 
10 
     | 
    
         
             
                # gem 'coffee-script' # Uncomment this line if you'd like to render executable CoffeeScript
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            Run the `render_execjs:install` generator to create the optional configuration initializer file
         
     | 
| 
         @@ -27,10 +27,35 @@ That's it! 
     | 
|
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
            Note that it will render whatever is returned from JavaScript.
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
      
 30 
     | 
    
         
            +
            ## Configuration ##
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            You can configure the following options:
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                environment # The environment in which to execute the JavaScript. For example, you can load the Jade templating library into this.
         
     | 
| 
      
 35 
     | 
    
         
            +
                coffeescript_environment # Will take CoffeeScript, compile it, and set environment to that
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            `render_execjs` supports four syntaxes for setting configuration options (using the environment option as an example):
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                RenderExecJS.configure do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  self.environment = "'js environment'"
         
     | 
| 
      
 41 
     | 
    
         
            +
                  environment "'js environment'"
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                RenderExecJS.environment = "'js environment'"
         
     | 
| 
      
 45 
     | 
    
         
            +
                RenderExecJS.environment "'js environment'"
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            And two for getting configuration options:
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                RenderExecJS.configure do
         
     | 
| 
      
 50 
     | 
    
         
            +
                  self.environment # => will return the environment
         
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                RenderExecJS.environment # => will also return the environment
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
       30 
55 
     | 
    
         
             
            ## Why would I want to render JavaScript from Rails? ##
         
     | 
| 
       31 
56 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
            Make sure that you're logged into your Twitter, now click on this link: [http://twitter.com/tazsingh](http://twitter.com/tazsingh)
         
     | 
| 
       33 
     | 
    
         
            -
            Notice how it loads your Twitter first, then the page that you've requested?
         
     | 
| 
      
 57 
     | 
    
         
            +
            Make sure that you're logged into your Twitter, now click on this link: [http://twitter.com/tazsingh](http://twitter.com/tazsingh).
         
     | 
| 
      
 58 
     | 
    
         
            +
            Notice how it loads your Twitter profile first, then the page that you've requested?
         
     | 
| 
       34 
59 
     | 
    
         | 
| 
       35 
60 
     | 
    
         
             
            It has to initialize the JavaScript environment before it can render the page you've requested.
         
     | 
| 
       36 
61 
     | 
    
         
             
            A solution to this, in Rails, is to use something like Mustache to render the same structure but with different logic;
         
     | 
| 
         @@ -1,22 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            RenderExecJS.configure do
         
     | 
| 
       2 
2 
     | 
    
         
             
            #  Add your RenderExecJS configuration here
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            #  Execute JS within environment from Sprockets
         
     | 
| 
       5 
     | 
    
         
            -
            #  compile_with :sprockets_require_tag
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
4 
     | 
    
         
             
            #  Execute JS within environment from File
         
     | 
| 
       8 
     | 
    
         
            -
            #   
     | 
| 
      
 5 
     | 
    
         
            +
            #  environment File.read("path/to/file")
         
     | 
| 
       9 
6 
     | 
    
         | 
| 
       10 
7 
     | 
    
         
             
            #  Execute JS within environment from String
         
     | 
| 
       11 
     | 
    
         
            -
            #   
     | 
| 
      
 8 
     | 
    
         
            +
            #  environment <<-JS
         
     | 
| 
       12 
9 
     | 
    
         
             
            #    // do stuff
         
     | 
| 
       13 
10 
     | 
    
         
             
            #  JS
         
     | 
| 
       14 
     | 
    
         
            -
            end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            #  Alternate setter syntax
         
     | 
| 
       17 
     | 
    
         
            -
            #  RenderExecJS.compile_with # value
         
     | 
| 
       18 
     | 
    
         
            -
            #  or
         
     | 
| 
       19 
     | 
    
         
            -
            #  RenderExecJS.compile_with = # value
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
            #  Alternate getter syntax
         
     | 
| 
       22 
     | 
    
         
            -
            #  RenderExecJS.compile_with # => value
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: render_execjs
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -13,7 +13,7 @@ date: 2012-02-06 00:00:00.000000000 Z 
     | 
|
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: rails
         
     | 
| 
       16 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: &70241333993820 !ruby/object:Gem::Requirement
         
     | 
| 
       17 
17 
     | 
    
         
             
                none: false
         
     | 
| 
       18 
18 
     | 
    
         
             
                requirements:
         
     | 
| 
       19 
19 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
         @@ -21,10 +21,10 @@ dependencies: 
     | 
|
| 
       21 
21 
     | 
    
         
             
                    version: 3.1.3
         
     | 
| 
       22 
22 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       23 
23 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       24 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: *70241333993820
         
     | 
| 
       25 
25 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       26 
26 
     | 
    
         
             
              name: execjs
         
     | 
| 
       27 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 27 
     | 
    
         
            +
              requirement: &70241333992000 !ruby/object:Gem::Requirement
         
     | 
| 
       28 
28 
     | 
    
         
             
                none: false
         
     | 
| 
       29 
29 
     | 
    
         
             
                requirements:
         
     | 
| 
       30 
30 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
         @@ -32,10 +32,10 @@ dependencies: 
     | 
|
| 
       32 
32 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       33 
33 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       34 
34 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       35 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 35 
     | 
    
         
            +
              version_requirements: *70241333992000
         
     | 
| 
       36 
36 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       37 
37 
     | 
    
         
             
              name: rspec
         
     | 
| 
       38 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 38 
     | 
    
         
            +
              requirement: &70241333988840 !ruby/object:Gem::Requirement
         
     | 
| 
       39 
39 
     | 
    
         
             
                none: false
         
     | 
| 
       40 
40 
     | 
    
         
             
                requirements:
         
     | 
| 
       41 
41 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
         @@ -43,10 +43,10 @@ dependencies: 
     | 
|
| 
       43 
43 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       44 
44 
     | 
    
         
             
              type: :development
         
     | 
| 
       45 
45 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       46 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 46 
     | 
    
         
            +
              version_requirements: *70241333988840
         
     | 
| 
       47 
47 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       48 
48 
     | 
    
         
             
              name: rspec-rails
         
     | 
| 
       49 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 49 
     | 
    
         
            +
              requirement: &70241333986840 !ruby/object:Gem::Requirement
         
     | 
| 
       50 
50 
     | 
    
         
             
                none: false
         
     | 
| 
       51 
51 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
52 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
         @@ -54,10 +54,10 @@ dependencies: 
     | 
|
| 
       54 
54 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       55 
55 
     | 
    
         
             
              type: :development
         
     | 
| 
       56 
56 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       57 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 57 
     | 
    
         
            +
              version_requirements: *70241333986840
         
     | 
| 
       58 
58 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       59 
59 
     | 
    
         
             
              name: coffee-script
         
     | 
| 
       60 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 60 
     | 
    
         
            +
              requirement: &70241334001440 !ruby/object:Gem::Requirement
         
     | 
| 
       61 
61 
     | 
    
         
             
                none: false
         
     | 
| 
       62 
62 
     | 
    
         
             
                requirements:
         
     | 
| 
       63 
63 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
         @@ -65,10 +65,10 @@ dependencies: 
     | 
|
| 
       65 
65 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       66 
66 
     | 
    
         
             
              type: :development
         
     | 
| 
       67 
67 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       68 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 68 
     | 
    
         
            +
              version_requirements: *70241334001440
         
     | 
| 
       69 
69 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       70 
70 
     | 
    
         
             
              name: appraisal
         
     | 
| 
       71 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: &70241333999160 !ruby/object:Gem::Requirement
         
     | 
| 
       72 
72 
     | 
    
         
             
                none: false
         
     | 
| 
       73 
73 
     | 
    
         
             
                requirements:
         
     | 
| 
       74 
74 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
         @@ -76,7 +76,7 @@ dependencies: 
     | 
|
| 
       76 
76 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       77 
77 
     | 
    
         
             
              type: :development
         
     | 
| 
       78 
78 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       79 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 79 
     | 
    
         
            +
              version_requirements: *70241333999160
         
     | 
| 
       80 
80 
     | 
    
         
             
            description: Execute server side JavaScript and render the result with Rails.
         
     | 
| 
       81 
81 
     | 
    
         
             
            email:
         
     | 
| 
       82 
82 
     | 
    
         
             
            - taz@zenapsis.com
         
     | 
| 
         @@ -120,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       120 
120 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       121 
121 
     | 
    
         
             
                  segments:
         
     | 
| 
       122 
122 
     | 
    
         
             
                  - 0
         
     | 
| 
       123 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 123 
     | 
    
         
            +
                  hash: 1899150468724932140
         
     | 
| 
       124 
124 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       125 
125 
     | 
    
         
             
              none: false
         
     | 
| 
       126 
126 
     | 
    
         
             
              requirements:
         
     | 
| 
         @@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       129 
129 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       130 
130 
     | 
    
         
             
                  segments:
         
     | 
| 
       131 
131 
     | 
    
         
             
                  - 0
         
     | 
| 
       132 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 132 
     | 
    
         
            +
                  hash: 1899150468724932140
         
     | 
| 
       133 
133 
     | 
    
         
             
            requirements: []
         
     | 
| 
       134 
134 
     | 
    
         
             
            rubyforge_project: render_execjs
         
     | 
| 
       135 
135 
     | 
    
         
             
            rubygems_version: 1.8.15
         
     |