jbuilder-jpartial 0.2.3 → 0.2.4

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: b3b16018a2a317dd73d9b7c335f36bb5617b4a71
4
- data.tar.gz: 32a5d28866d2253646d97d6b7c88c4e47352f9f7
3
+ metadata.gz: '0678a8be58d6a3469f3d25214d69aacfea9b3e63'
4
+ data.tar.gz: 314f6cddd18c7c9140fa7aae548b385c43232858
5
5
  SHA512:
6
- metadata.gz: 3ae11bfc5c2936ab47a50b5875bcb8c481a75a582db3d0be1e300dd9586685688542910191ed0872db8654ed79aae45ffb1a970607ec65ef3e0b34e3df6bcd8c
7
- data.tar.gz: 1642559e330f11d60c8dc6da29213e1642dc30e51fad449e75cc058da9b489b65f2fc7971419dc2e9bfec7115e5ff4e4adf06fb0e603ab6a03992f2293efde97
6
+ metadata.gz: abd034de8322e17d784545c923dd9f84932491ec14f0a341951b06088dbfb683607c3a105c8d7d7c892da2ec348e7f2bf90b593012a1bfc9b00137879070d938
7
+ data.tar.gz: f235af7623dae7aca81358e37f5a3597909ce971623bdeadb5f3066bded9644eb6b3e903624fb2d29fa0381ce60d476e3cc8cb18c1c77ec6720688f8de12f7f2
data/README.md CHANGED
@@ -74,9 +74,9 @@ When partials are used with `Jbuilder` render times and memory usage can skyrock
74
74
 
75
75
  Using a simple DSL, `Jbuilder::Jpartial` lets you define your partials in a familiar way while dramatically reducing overhead.
76
76
 
77
- The result is faster rendering and lower memory usage, while still being able to leverage the advantages of Jbuilder. In the above example, if we had used standard Jbuilder partials those templates would have to be rendered once for each `post` and/or `comment`. If you have 50 posts, each with 50 comments, that's 2,500 templates rendered! Using `Jbuilder::Jpartial`, the partial files are each only called once, to define the partial. After that, all of the partial rendering is taken care of in the abstract from the original file. In our example, you can cut 2,500 template renders down to 3.
77
+ The result is faster rendering and lower memory usage, while still being able to leverage the advantages of Jbuilder. In the above example, if we had used standard Jbuilder partials those templates would have to be rendered once for each `post` and/or `comment`. If you have 50 posts, each with 50 comments, that's 2,550 templates rendered! Using `Jbuilder::Jpartial`, the partial files are each only called when the partial is initialized. After that, all of the partial rendering is taken care of in the abstract from the original file. In our example, we hit `json.partial! 'post'` once and `json.partial! 'comments/comment' only once for each `post`, cutting 2,550 template renders down to 51.
78
78
 
79
- Alternatively you can define all partials in one initializer file and call them wherever you need them: from within other partial definitions or anywhere you use `Jbuilder` in your views. The advantage here is fewer files, all partials in one place, and since they're initialized at start up, you don't need to call any additional view templates to render the partials. Using the same example as above:
79
+ Alternatively you can define all partials in one initializer file and call them wherever you need them: from within other partial definitions or anywhere you use `Jbuilder` in your views. The big advantage here is since they're initialized at start up, you don't need to call any additional view templates to render the partials. Using the same example as above:
80
80
 
81
81
  #### In `app/config/initializers/jpartial.rb`
82
82
  ```ruby
@@ -106,7 +106,7 @@ end
106
106
 
107
107
  Notice that when using this method, we don't make any calls like `json.partial! 'post'` at any point to define the partial before using it. All of the partials are already defined in the initializer file.
108
108
 
109
- The advantage is even fewer renders and faster responses. The only real disadvantage is it bucks the regular Rails partial conventions. C'est la vie.
109
+ We've now cut our template renders down to only 1 from the original 2,550. The only real disadvantage is it bucks the regular Rails file structure conventions for partials. C'est la vie.
110
110
 
111
111
  #### How?
112
112
  Each method you call on `jpartial` defines a Jbuilder method of the same name. The objects you will pass to that method are yielded to the block. Inside the block you can use plain old Jbuilder syntax.
@@ -1,5 +1,5 @@
1
1
  class Jbuilder
2
2
  module Jpartial
3
- VERSION = '0.2.3'.freeze
3
+ VERSION = '0.2.4'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbuilder-jpartial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. Simon Borg