Yeah, I was playing around with that stuff a little. There's lots of
splatting and un-splatting going on with capturing - it gets a little
tangled. I'll have a look at it soon.
Also, just a note: you may want to check out some of the Haml helpers
for printing out text. We have our own concat that doesn't require a
binding, as well as a redefinition of "puts" which respects the current
indentation level.
- Nathan
Robin wrote:
> I noticed that the latest svn release of Haml broke my project. On
> further inspection I noticed that it was due to a helper I had to
> iterate through a collection and build table rows that looks something
> like this:
>
> def trc(collection = nil, &block)
> collection.each do |record|
> content = capture(record, &block)
> concat(tag(:tr, {:class => cycle('even', 'odd')}, true),
> block.binding)
> concat(content, block.binding)
> concat("</tr>", block.binding)
> end
> end
>
> I call the above helper like this:
>
> - trc @users do |user|
> %td= user[:name]
>
> When running the above code on the results from an ActiveRecord query,
> it was passing the ActiveRecord row in an array to my block instead of
> the object itself. After investigating, I believe that "yield args"
> in lib/haml/helpers.rb (around line 293) should be yield *args. I've
> submitted a patch for this, and a test to show that it works.
>
> HOWEVER, this patch seems to break another test,
> test_list_of_should_render_correctly, which is suspicious. The part
> of the test that fails is this:
>
> assert_equal("<li>1</li>\n", render("= list_of([[1]]) do |i|\n =
> i.first"))
>
> The reason it fails is that it tries to call .first on the FixNum
> instead of on [1], which sounds like I've mucked it up somehow.
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---