tilt-jbuilder 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/lib/tilt/jbuilder.rb +7 -7
- data/spec/templates/_profile.json.jbuilder +1 -0
- data/spec/templates/_user.json.jbuilder +4 -0
- data/spec/tilt-jbuilder_spec.rb +5 -0
- data/tilt-jbuilder.gemspec +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adb2c4775b0a1a4305977f379e9ebeba7f551807
|
4
|
+
data.tar.gz: 53e905dfc2af7c6f8994acacbdf9e8ee395a2702
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52c7dc71efb25bcbae0b38fda2e3192e6727410b901499396524fa12d306b686a6418b29f243852d75164b31c21da59ae41fc9a38869093c57db96b9935c3af
|
7
|
+
data.tar.gz: f54090778bc6be712029e5b21ad58b574ae9c4134af0711861631602d01b532a5f5ea67e2b2e1d094890ac601312d159a61eaf11834410519e3c1f5401f7c184
|
data/.travis.yml
CHANGED
data/lib/tilt/jbuilder.rb
CHANGED
@@ -22,8 +22,8 @@ module Tilt
|
|
22
22
|
end
|
23
23
|
|
24
24
|
view_path = @scope.instance_variable_get('@_jbuilder_view_path')
|
25
|
-
|
26
|
-
render_partial_with_options options
|
25
|
+
template = ::Tilt::JbuilderTemplate.new(fetch_partial_path(options[:partial].to_s, view_path), nil, view_path: view_path)
|
26
|
+
render_partial_with_options template, options
|
27
27
|
end
|
28
28
|
|
29
29
|
def array!(collection = [], *attributes, &block)
|
@@ -53,7 +53,7 @@ module Tilt
|
|
53
53
|
partial_file.join("/")
|
54
54
|
end
|
55
55
|
|
56
|
-
def render_partial_with_options(options)
|
56
|
+
def render_partial_with_options(template, options)
|
57
57
|
options[:locals] ||= {}
|
58
58
|
if options[:as] && options.key?(:collection)
|
59
59
|
collection = options.delete(:collection)
|
@@ -61,16 +61,16 @@ module Tilt
|
|
61
61
|
array! collection do |member|
|
62
62
|
member_locals = locals.clone
|
63
63
|
member_locals.merge! options[:as] => member
|
64
|
-
render_partial member_locals
|
64
|
+
render_partial template, member_locals
|
65
65
|
end
|
66
66
|
else
|
67
|
-
render_partial options[:locals]
|
67
|
+
render_partial template, options[:locals]
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
def render_partial(options)
|
71
|
+
def render_partial(template, options)
|
72
72
|
options.merge! json: self
|
73
|
-
|
73
|
+
template.render @scope, options
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -0,0 +1 @@
|
|
1
|
+
json.name profile[:name]
|
data/spec/tilt-jbuilder_spec.rb
CHANGED
@@ -90,5 +90,10 @@ describe Tilt::JbuilderTemplate do
|
|
90
90
|
let(:template_body) { "json.array! ['foo', 'bar'], partial: 'spec/templates/collection_partial', as: :name" }
|
91
91
|
it { is_expected.to eq %q/[{"attribute":"foo"},{"attribute":"bar"}]/ }
|
92
92
|
end
|
93
|
+
|
94
|
+
context 'when use subpartials' do
|
95
|
+
let(:template_body) { "json.array! [{id: 1, profile: {name: 'Foo'}},{id: 2, profile: {name: 'Bar'}}], partial: 'spec/templates/user', as: :user" }
|
96
|
+
it { is_expected.to eq %q/[{"id":1,"profile":{"name":"Foo"}},{"id":2,"profile":{"name":"Bar"}}]/ }
|
97
|
+
end
|
93
98
|
end
|
94
99
|
end
|
data/tilt-jbuilder.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tilt-jbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tilt
|
@@ -85,6 +85,8 @@ files:
|
|
85
85
|
- spec/support/views/invalid.jbuilder
|
86
86
|
- spec/templates/_collection_partial.json.jbuilder
|
87
87
|
- spec/templates/_partial.json.jbuilder
|
88
|
+
- spec/templates/_profile.json.jbuilder
|
89
|
+
- spec/templates/_user.json.jbuilder
|
88
90
|
- spec/tilt-jbuilder_spec.rb
|
89
91
|
- tilt-jbuilder.gemspec
|
90
92
|
homepage: https://github.com/anthonator/tilt-jbuilder
|
@@ -106,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
108
|
version: '0'
|
107
109
|
requirements: []
|
108
110
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.5.1
|
110
112
|
signing_key:
|
111
113
|
specification_version: 4
|
112
114
|
summary: Adds support for rendering Jbuilder templates in Tilt.
|
@@ -123,4 +125,6 @@ test_files:
|
|
123
125
|
- spec/support/views/invalid.jbuilder
|
124
126
|
- spec/templates/_collection_partial.json.jbuilder
|
125
127
|
- spec/templates/_partial.json.jbuilder
|
128
|
+
- spec/templates/_profile.json.jbuilder
|
129
|
+
- spec/templates/_user.json.jbuilder
|
126
130
|
- spec/tilt-jbuilder_spec.rb
|