Okay, it's some sort of problem with how we detect Haml-ness or find the
Haml template. If you apply the attached patch to Haml, does it work?
Sean Santry wrote:
> On Oct 7, 1:27 pm, Nathan Weizenbaum <[EMAIL PROTECTED]> wrote:
>
>> Does it work if you move the content_for call out of the helper and into
>> the Haml template?
>>
>
> Yup, a content_for with a block works fine if it's in the template.
> Also if I use content_for(:sidebar, render(:partial => 'foo')) in the
> helper (instead of passing a block) it works.
>
> BTW, sorry for the multiple copies of the original post. I have no
> idea how that happened. I clicked send only once, I swear!
>
> - Sean
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
diff --git a/lib/haml/helpers.rb b/lib/haml/helpers.rb
index cd7d025..3b219ac 100644
--- a/lib/haml/helpers.rb
+++ b/lib/haml/helpers.rb
@@ -254,26 +254,23 @@ module Haml
# the local variable <tt>foo</tt> would be assigned to "<p>13</p>\n".
#
def capture_haml(*args, &block)
- buffer = eval('_hamlout', block) rescue haml_buffer
- with_haml_buffer(buffer) do
- position = haml_buffer.buffer.length
+ position = haml_buffer.buffer.length
- block.call(*args)
+ block.call(*args)
- captured = haml_buffer.buffer.slice!(position..-1)
+ captured = haml_buffer.buffer.slice!(position..-1)
- min_tabs = nil
- captured.each do |line|
- tabs = line.index(/[^ ]/)
- min_tabs ||= tabs
- min_tabs = min_tabs > tabs ? tabs : min_tabs
- end
+ min_tabs = nil
+ captured.each do |line|
+ tabs = line.index(/[^ ]/)
+ min_tabs ||= tabs
+ min_tabs = min_tabs > tabs ? tabs : min_tabs
+ end
- result = captured.map do |line|
- line[min_tabs..-1]
- end
- result.to_s
+ result = captured.map do |line|
+ line[min_tabs..-1]
end
+ result.to_s
end
# Outputs text directly to the Haml buffer, with the proper tabulation
diff --git a/lib/haml/precompiler.rb b/lib/haml/precompiler.rb
index d84e97e..0bf76d0 100644
--- a/lib/haml/precompiler.rb
+++ b/lib/haml/precompiler.rb
@@ -259,7 +259,7 @@ END
def flush_merged_text
return if @merged_text.empty?
- @precompiled << "_hamlout.push_text([EMAIL PROTECTED]"
+ @precompiled << "@haml_buffer.push_text([EMAIL PROTECTED]"
@precompiled << ", [EMAIL PROTECTED]" if @dont_tab_up_next_text || @tab_change != 0
@precompiled << ", [EMAIL PROTECTED]" if @tab_change != 0
@precompiled << ");"
@@ -304,7 +304,7 @@ END
newline_now
args = [preserve_script, in_tag, preserve_tag,
escape_html, nuke_inner_whitespace].map { |a| a.inspect }.join(', ')
- out = "haml_temp = _hamlout.push_script(haml_temp, #{args});"
+ out = "haml_temp = @haml_buffer.push_script(haml_temp, #{args});"
if block_opened?
push_and_tabulate([:loud, out])
else
@@ -588,7 +588,7 @@ END
args = [tag_name, self_closing, !block_opened?, preserve_tag, escape_html,
attributes, nuke_outer_whitespace, nuke_inner_whitespace
].map { |v| v.inspect }.join(', ')
- push_silent "_hamlout.open_tag(#{args}, #{object_ref}, #{content}#{attributes_hash})"
+ push_silent "@haml_buffer.open_tag(#{args}, #{object_ref}, #{content}#{attributes_hash})"
@dont_tab_up_next_text = @dont_indent_next_line = dont_indent_next_line
end