tilt-jbuilder 0.7.0 → 0.7.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3479ae47f34755751c8800f0a303dc2452ad0ccd
4
- data.tar.gz: edede33e7a7235d4875d36f74a6550cfc5b892d6
3
+ metadata.gz: adb2c4775b0a1a4305977f379e9ebeba7f551807
4
+ data.tar.gz: 53e905dfc2af7c6f8994acacbdf9e8ee395a2702
5
5
  SHA512:
6
- metadata.gz: 3c18a29f7da6f6402d91ba959b0677564c504178656070cb4f763b82f2fe085c588a0ceb89fdd4a0ead5b638664e211742864e97deb80457bada32d59838f82b
7
- data.tar.gz: bcf3903c08e27aea78be98e7085b35410f936b0ba4fefc7a5ea553176acb12268dc07498a8498d450cfc876494964e3cda328f89f396516b4b480a888eaa56af
6
+ metadata.gz: d52c7dc71efb25bcbae0b38fda2e3192e6727410b901499396524fa12d306b686a6418b29f243852d75164b31c21da59ae41fc9a38869093c57db96b9935c3af
7
+ data.tar.gz: f54090778bc6be712029e5b21ad58b574ae9c4134af0711861631602d01b532a5f5ea67e2b2e1d094890ac601312d159a61eaf11834410519e3c1f5401f7c184
@@ -9,9 +9,12 @@ rvm:
9
9
  - 2.1.4
10
10
  - 2.1.5
11
11
  - 2.2.0
12
+ - 2.3.0
12
13
  - ruby-head
13
14
  - jruby-19mode
14
15
  - jruby-head
16
+ before_install:
17
+ - gem install bundler
15
18
  matrix:
16
19
  allow_failures:
17
20
  - rvm: ruby-head
@@ -22,8 +22,8 @@ module Tilt
22
22
  end
23
23
 
24
24
  view_path = @scope.instance_variable_get('@_jbuilder_view_path')
25
- @template = ::Tilt::JbuilderTemplate.new(fetch_partial_path(options[:partial].to_s, view_path), nil, view_path: view_path)
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
- @template.render @scope, options
73
+ template.render @scope, options
74
74
  end
75
75
  end
76
76
 
@@ -0,0 +1 @@
1
+ json.name profile[:name]
@@ -0,0 +1,4 @@
1
+ json.id user[:id]
2
+ json.profile do |json|
3
+ json.partial! 'spec/templates/profile', profile: user[:profile]
4
+ end
@@ -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
@@ -16,5 +16,5 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(/^(test|spec|features)\//)
17
17
  gem.name = 'tilt-jbuilder'
18
18
  gem.require_paths = ['lib']
19
- gem.version = '0.7.0'
19
+ gem.version = '0.7.1'
20
20
  end
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.0
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: 2015-07-12 00:00:00.000000000 Z
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.4.5
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