Thanks Nathan for looking into it and pushing a fix. Cheers, David
On Oct 14, 6:10 pm, Nathan Weizenbaum <[email protected]> wrote: > Yeah, this is indeed a bug. I've pushed a fix, which'll be released in > 2.2.9, which I'll probably put out this weekend. > > On Wed, Oct 14, 2009 at 10:13 AM, David Blondeau > <[email protected]>wrote: > > > Nathan, > > > I understand having nested capture and capture_haml is not the best and we > > usually try not to do it. > > > We have some custom generic view helpers for our application that generate > > in place editing of data section (one data section has a link to edit that > > section. That section is replaced (hide/show) on click by a form). > > To generate those, we need to capture the result of the rails form_for and > > remote_form_for helper methods. The content of that being defined in the > > Haml template, we need to capture_haml it... > > > Something reading like that: > > > = editable_data(person, ...) do |panel| > > - panel.show_data_table do |table| > > = table.row(:first_name) > > = table.row(:last_name) > > ... > > > - panel.edit(...) do |form| > > = form.errors > > %table > > %tbody > > = form.row(:first_name) > > = form.row(:last_name) > > ... > > > Still, 2.0 works fine with those nested capture and capture_haml. It would > > be nice if we can get 2.2 to do it as well. > > > Any idea why _erbout and _hamlout.buffer are out of sync in the example I > > gave in the original post? > > Would it be OK to use _hamlout.buffer in place of _erbout in push_script? > > > Thanks, > > David > > > On Wed, Oct 14, 2009 at 9:07 AM, Nathan Weizenbaum <[email protected]>wrote: > > >> Why are you mixing #capture and #capture_haml? That seems like a recipe > >> for trouble, and indeed seems to be what's causing this particular issue. > > >> On Tue, Oct 13, 2009 at 8:34 PM, David <[email protected]> wrote: > > >>> Hi, > > >>> We are upgrading the Haml library (from 2.0.7 to 2.2.8) used for our > >>> Rails (2.2.3) application > >>> We are seeing an issue where the result of a script ( = helper_method > >>> (...) ) is appended to the wrong buffer in a specific case. > > >>> Here is a simple example that reproduces the issue (the actual logic > >>> is actually spread over several helper methods like form helpers and > >>> other view helpers): > > >>> In ApplicationHelper > >>> def nested_captures > >>> capture do > >>> capture_haml do > >>> haml_concat "start" > >>> haml_concat(capture_haml { > >>> haml_concat "yeah" > >>> yield(self) > >>> }) > >>> haml_concat "end" > >>> end > >>> end > >>> end > > >>> And in the Haml template: > >>> .section > >>> .message > >>> = nested_captures do |template| > >>> foo > >>> = succeed(",") do > >>> bar > > >>> With 2.2.8, we are getting: > >>> <div class='section'> > >>> <div class='message'> > >>> bar, start > >>> yeah > >>> foo > > >>> end > >>> </div> > >>> </div> > > >>> Looking at precompiler.rb, at the end of push_script: > >>> push_and_tabulate([:loud, "_erbout << #{no_format ? "# > >>> {output_temp}.to_s;" : out}", > >>> !(opts[:in_tag] || opts[:nuke_inner_whitespace] || @options > >>> [:ugly])]) > > >>> If we replace _erbout by _hamlout.buffer (like it was in 2.0.7) > >>> push_and_tabulate([:loud, "__hamlout.buffer << #{no_format ? "# > >>> {output_temp}.to_s;" : out}", > >>> !(opts[:in_tag] || opts[:nuke_inner_whitespace] || @options > >>> [:ugly])]) > > >>> then we get the expected result > >>> <div class='section'> > >>> <div class='message'> > > >>> start > >>> yeah > >>> foo > >>> bar, > > >>> end > >>> </div> > >>> </div> > > >>> This seems to indicate that _erbout is not set correctly for the = > >>> succeed... . > >>> Not sure why _erbout != _hamlout.buffer at that point but thought I > >>> would ask if someone can shed some light on the issue before we dig > >>> further. > > >>> Thanks, > >>> David > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/haml?hl=en -~----------~----~----~----~------~----~------~--~---
