Skip to content

Commit

Permalink
let's ensure that :layout and :spacer_template are not passed
Browse files Browse the repository at this point in the history
  • Loading branch information
skatkov committed Oct 20, 2023
1 parent 66c4936 commit b391496
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/pbbuilder/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ def set!(field, *args, **kwargs, &block)
options[:locals].merge!(pb: self)
options[:locals].merge!(field: field)

result = CollectionRenderer
.new(@context.lookup_context, options) { |&block| _scope(message[field.to_s],&block) }
.render_collection_with_partial(collection, partial, @context, nil)
if options.has_key?(:layout)
raise ::NotImplementedError, "The `:layout' option is not supported in collection rendering."
end

if options.has_key?(:spacer_template)
raise ::NotImplementedError, "The `:spacer_template' option is not supported in collection rendering."
end

CollectionRenderer
.new(@context.lookup_context, options) { |&block| _scope(message[field.to_s],&block) }
.render_collection_with_partial(collection, partial, @context, nil)
else
# pb.best_friend partial: "person", person: @best_friend
# Call set! as a submessage, passing in the kwargs as partial options
Expand Down

0 comments on commit b391496

Please sign in to comment.