First of all, you don't need to use "end" with Haml. You can use indentation
instead to delineate the structure of blocks and statements. for example:

!!! XML
!!! 1.1
%html{ html_attrs('fr-fr') }
 %head
   %title= yield :title
 %body
   - [:notice, :error, :message].each do |key|
     - unless flash[key].blank?
       %p{ :class => "flash flash_#{key}" }= flash[key]
   #contents
     = yield

I'm not sure what's wrong with the second example. You'll have to give more
information about the erroneous output.

- Nathan

On Tue, Apr 1, 2008 at 11:08 AM, Pierre Y. <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I have problems to add contents of the flash hash to the result page.
>
> I succeeded with this code :
>
> !!! XML
> !!! 1.1
> %html{ html_attrs('fr-fr') }
>  %head
>    %title= yield :title
>  %body
>    - [:notice, :error, :message].each do |key|
>    - unless flash[key].blank? then
>      %p{ :class => "flash flash_#{key}" }= flash[key]
>    - end
>    #contents
>      = yield
>
> But I failed using one the the flash helpers that exists on the web :
>
> module ApplicationHelper
>
>  def show_flash
>    [:notice, :warning, :message].collect do |key|
>      content_tag(:div, flash[key], :class => "flash flash_#{key}") if
> flash[key]
>    end.join
>  end
>
>  def flash_helper
>    f_names = [:notice, :warning, :message]
>    fl = ''
>
>    for name in f_names
>      if flash[name]
>        fl = fl + "<div class=\"notice\" id=\"#{name}
> \">#{flash[name]}</div>"
>      end
>      flash[name] = nil;
>    end
>    return fl
>  end
>
> end
>
> I tried to use them this way :
>
> !!! XML
> !!! 1.1
> %html{ html_attrs('fr-fr') }
>  %head
>    %title= yield :title
>  %body
>    = show_flash            <---- here, or "flash_helper" with the
> same result.
>    #contents
>      = yield
>
> But nothing happens. What's wrong ?
>
> Regards,
>
> --
> Pierre Yager
> >
>

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