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 +4 -4
- data/README.md +5 -5
- data/lib/jbuilder/jpartial.rb +4 -0
- data/lib/jbuilder/jpartial/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd2f9434cebd1a5017cad21be3ca7fea80c032df
|
4
|
+
data.tar.gz: d2411db16a9402ca9e6c4598cc04369b0c2aba80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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/
|
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
|
-
|
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
|
-
|
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
|
-
|
115
|
+
Jbuilder::Jpartial.configure do
|
116
116
|
jpartial :_post do |post|
|
117
117
|
json.href post_url(post)
|
118
118
|
json.title post.title
|
data/lib/jbuilder/jpartial.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jbuilder
|