Regression: Prepend has stopped working with latest changes
Reported by Ignacio Huerta | September 30th, 2011 @ 05:41 PM | in Hobo 1.3 (Rails 3)
Hi,
I just discovered that the prepend pseudo parameter has stopped working since Hobo 1.3.0.RC2. An example in a very simple app:
<show-page:>
<prepend-content-body:>
<h1>Hello</h1>
</prepend-content-body:>
</show-page:>
It works with Hobo 1.3.0.RC2, but it doesn't with the latest code from Github. Before, after and append still work. I'd like to help find the bug, but I'm a bit lost about where to start.
Comments and changes to this ticket
-
Matt Jones October 9th, 2011 @ 09:01 PM
(from [2498d176614a6ec016db6efe0f29ca9f83c9b243]) [#970] fix handling of before/after/prepend/append params with new ERB parser https://github.com/tablatom/hobo/commit/2498d176614a6ec016db6efe0f2...
-
Matt Jones October 9th, 2011 @ 09:12 PM
- State changed from new to resolved
- Milestone set to Hobo 1.3 (Rails 3)
- Milestone order changed from 197985 to 0
Alright, finally ran this down. The core difficulty was an obscure case in Ruby syntax, where a setter (method ending in
=
) always returns its argument. This caused the problem sinceActionView::OutputBuffer
aliases<<
toappend=
, which we use to get block-helper compatibility working. In short, code like this:<extend tag="form" for="Task"> <old-form merge> <after-field-list:><%= 'FOO' %></after-field-list:> </old-form> </extend>
winds up with this compiled ERB at its heart:
:field_list_replacement => proc { |_field_list_restore| new_context { ; concat(_field_list_restore.call({}, {})) ; self.output_buffer.append= ( 'FOO' ); } },
which gets the WRONG return value. Even something as simple as adding blank lines can change this:
<extend tag="form" for="Task"> <old-form merge> <after-field-list:> <%= 'FOO' %> </after-field-list:> </old-form> </extend>
yields:
:field_list_replacement => proc { |_field_list_restore| new_context { ; concat(_field_list_restore.call({}, {})) ; self.output_buffer.safe_concat("\n"); self.output_buffer.safe_concat(' '); self.output_buffer.append= ( 'FOO' ); self.output_buffer.safe_concat("\n"); } },
which returns the correct value, since
safe_concat
returns the whole buffer.The fix included in the patch above should cover ANY possible case, since it ensures that each set of ERB
<%= %>
tags always returns the output buffer.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป