I've just fixed this in master and stable.

ngocdaothanh wrote:
> Hi all.
>
> 1. Problem when using HAML with Rails 2.2.2
>
> Please see the method non_haml in the file lib/haml/helpers.rb (http://
> github.com/mislav/haml/tree/master/lib%2Fhaml%2Fhelpers.rb).
>
> -----------------
>     def non_haml
>       was_active = @haml_buffer.active?
>       @haml_buffer.active = false
>       res = yield
>       @haml_buffer.active = was_active
>       res
>     end
> -----------------
>
> When there is exception in yield, was_active is not resumed, thus may
> cause problem. I think the code should be:
>
> -----------------
>     def non_haml
>       was_active = @haml_buffer.active?
>       begin
>         @haml_buffer.active = false
>         res = yield
>       ensure
>         @haml_buffer.active = was_active
>       end
>       res
>     end
> -----------------
>
> 2. Example
>
> The following method does not work as expected when given a non
> existant template:
> -----------------
> Helper:
>   # Render only if the template exists.
>   def render_if_exists(*args)
>     render(*args)
>   rescue ActionView::MissingTemplate
>     block_given? ? yield : ''
>   end
>
> View:
>   = 'string1'
>   = render_if_exists(:partial => 'non existant template')
>   = 'string2'
> -----------------
>
> The above view is broken and string2 will not be rendered because:
> * When ActionView::MissingTemplate exception occurs, was_active is not
> resumed
> * The buffer becomes nil in concat method of Rails
>
> Regards,
> Ngoc.
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to