Skip to content

Commit d4c8827

Browse files
authored
Merge pull request #578 from ienders/force-close-final-template-statement
2 parents 418cd97 + f0a88b3 commit d4c8827

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/jbuilder/jbuilder_template.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def _render_partial_with_options(options)
159159
results = CollectionRenderer
160160
.new(@context.lookup_context, options) { |&block| _scope(&block) }
161161
.render_collection_with_partial(collection, partial, @context, nil)
162-
162+
163163
array! if results.respond_to?(:body) && results.body.nil?
164164
else
165165
array!
@@ -284,7 +284,7 @@ class JbuilderHandler
284284
def self.call(template, source = nil)
285285
source ||= template.source
286286
# this juggling is required to keep line numbers right in the error
287-
%{__already_defined = defined?(json); json||=JbuilderTemplate.new(self); #{source}
287+
%{__already_defined = defined?(json); json||=JbuilderTemplate.new(self); #{source};
288288
json.target! unless (__already_defined && __already_defined != "method")}
289289
end
290290
end

test/jbuilder_template_test.rb

+11
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ class JbuilderTemplateTest < ActiveSupport::TestCase
4949
assert_equal "hello", result["content"]
5050
end
5151

52+
test "partial by name with hash value omission (punning) as last statement [3.1+]" do
53+
major, minor, _ = RUBY_VERSION.split(".").map(&:to_i)
54+
return unless (major == 3 && minor >= 1) || major > 3
55+
56+
result = render(<<-JBUILDER)
57+
content = "hello"
58+
json.partial! "partial", content:
59+
JBUILDER
60+
assert_equal "hello", result["content"]
61+
end
62+
5263
test "partial by options containing nested locals" do
5364
result = render('json.partial! partial: "partial", locals: { content: "hello" }')
5465
assert_equal "hello", result["content"]

0 commit comments

Comments
 (0)