jbuilder-jpartial 0.1.1 → 0.1.2

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: 9ad88768f1ae41076a9175f1e90174a0bdc80638
4
- data.tar.gz: 2778476a2b04bb6eeb0f42ec7665153517385e10
3
+ metadata.gz: fd2f9434cebd1a5017cad21be3ca7fea80c032df
4
+ data.tar.gz: d2411db16a9402ca9e6c4598cc04369b0c2aba80
5
5
  SHA512:
6
- metadata.gz: f0fe6936a7c608dae8c010d31b36152d336900895fc7fee47bdcab6899fd0e6954f6210b8524a45e708fc570e382dd305a5fb7a97b99dfc406822c5a91d2d4cf
7
- data.tar.gz: 954402549203c09e2a541ed673b615380ad7c6abd2571acfb192ef7dd82a4c8bd27a92b2cf434b7119e175203c2500fe36de5335f33ad4433de06a36161ffdc6
6
+ metadata.gz: f4b7ea3b7df144a67dac206210cba740d1f5bea80c948fde961122243bdb4da4d2f9559b1a2a7b0471a96a3352e0918144ce2868be1c9199c3c4dba6dd02dbc2
7
+ data.tar.gz: a9778f7acc70ae28acd6421bdfaa29e8341f4578131913e83da817f018a5e168fef69565ebad0b102f53242b018cfcaf5fb67042c12b5f291f16ea28eba3358f
data/README.md CHANGED
@@ -25,7 +25,7 @@ Or install it yourself as:
25
25
  #### In `config/initializers/jbuilder-jpartial.rb`
26
26
 
27
27
  ```ruby
28
- module Jbuilder::Jpartial
28
+ Jbuilder::Jpartial.configure do
29
29
  jpartial :_post do |post|
30
30
  json.title post.title
31
31
  json.author post.author.name
@@ -71,7 +71,7 @@ When traditional partials are used with `Jbuilder`, with each partial in a diffe
71
71
 
72
72
  Using a simple DSL, `Jbuilder::Jpartial` lets you 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.
73
73
 
74
- 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 traditional partials (defined in `app/views/posts/_post.jbuilder` and `app/views/posts/_comment.jbuilder`) 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`, only one file (`app/views/posts/index.jbuilder`) is rendered. All of the partial rendering is taken care of in the abstract.
74
+ 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 traditional partials (defined in `app/views/posts/_post.jbuilder` and `app/views/comments/_comment.jbuilder`) 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`, only one file (`app/views/posts/index.jbuilder`) is rendered. All of the partial rendering is taken care of in the abstract.
75
75
 
76
76
  #### How?
77
77
  Each `jpartial` block in your initializer file defines a Jbuilder method named after whatever symbol you pass as an argument. The objects you will pass to that method are yielded to the block. Inside the block you can use plain old Jbuilder syntax.
@@ -79,7 +79,7 @@ Each `jpartial` block in your initializer file defines a Jbuilder method named a
79
79
  e.g.
80
80
 
81
81
  ```ruby
82
- module Jbuilder::Jpartial
82
+ Jbuilder::Jpartial.configure do
83
83
  jpartial :_post do |post|
84
84
  json.title post.title
85
85
  end
@@ -93,7 +93,7 @@ You can specify multiple arguments and even use keyword arguments if you need to
93
93
  e.g.
94
94
 
95
95
  ```ruby
96
- module Jbuilder::Jpartial
96
+ Jbuilder::Jpartial.configure do
97
97
  jpartial :_post do |post, author:|
98
98
  json.title post.title
99
99
  json._author author
@@ -112,7 +112,7 @@ Route helpers that are available within the views can also be used in the config
112
112
  e.g.
113
113
 
114
114
  ```ruby
115
- module Jbuilder::Jpartial
115
+ Jbuilder::Jpartial.configure do
116
116
  jpartial :_post do |post|
117
117
  json.href post_url(post)
118
118
  json.title post.title
@@ -30,5 +30,9 @@ class Jbuilder
30
30
  end
31
31
  end
32
32
  end
33
+
34
+ def self.configure(&block)
35
+ module_eval(&block)
36
+ end
33
37
  end
34
38
  end
@@ -1,5 +1,5 @@
1
1
  class Jbuilder
2
2
  module Jpartial
3
- VERSION = '0.1.1'.freeze
3
+ VERSION = '0.1.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbuilder-jpartial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. Simon Borg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-10 00:00:00.000000000 Z
11
+ date: 2017-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jbuilder