Allows the block to be run in the context it was defined. Block parameter is now mandatory.
Simple example in Rails view:
# I want to group this:
pdf.text t('some.translation')
pdf.text 'some other text'
# --> I can simply wrap it around now
pdf.group.do |g|
g.text t('some.translation')
g.text 'some other text'
end
Without this PR, t is not defined because it does not exist in the changed context. It had to be done like this:
translation = t('some.translation')
group.do |g|
g.text translation
g.text 'some other text'
end
This can get really messy if you want to group more complex things.
With this PR, the context is not changed anymore.
Only downside: The block parameter is mandatory, not only in jruby. But IMO the context should not be changed because it complicates things more than it solves (only benefit: the optional block parameter).
Late but still: I am currently updating the project and I integrated your changes to yield alongside some other updates. Will release the next version of prawn grouping with it.
Allows the block to be run in the context it was defined. Block parameter is now mandatory.
Simple example in Rails view:
Without this PR,
t
is not defined because it does not exist in the changed context. It had to be done like this:This can get really messy if you want to group more complex things.
With this PR, the context is not changed anymore.
Only downside: The block parameter is mandatory, not only in
jruby
. But IMO the context should not be changed because it complicates things more than it solves (only benefit: the optional block parameter).