List Info

Thread: Question on how to display blocks in Haml? Getting string and nil errors




Question on how to display blocks in Haml? Getting string and nil errors
country flaguser name
United States
2007-09-02 09:10:56
Hello All,

First off, I love haml/sass and it's changing the way I work
for the
better, but I'm having some problems wrapping my head
around
something.

          <% flash.each do |name, msg| %>
		        <%= content_tag :div, msg, :id =>
"flash_#" %>
		      <% end %>

Take that for example, I can't quite figure out how to make
that
display correctly without getting a "can't convert nil
into String"
error.  Anyone have some advice?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Question on how to display blocks in Haml? Getting string and nil errors
user name
2007-09-02 10:00:48
You can just write a helper, check this out:
http://blog.wolfman.com/articles/2007/07/14/using-rspec-to-test-haml-helpers


On 9/2/07, Malko < robmalkogmail.com">robmalkogmail.com> wrote:

Hello All,

First off, I love haml/sass and it's changing the way I work for the
better, but I'm having some problems wrapping my head around
something.

&nbsp; &nbsp;   ; &nbsp; &nbsp;<% flash.each do |name, msg| %>
&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &lt;%= content_tag :div, msg, :id => "flash_#&quot; %>
&nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; <% end %>

Take that for example, I can't quite figure out how to make that
display correctly without getting a "can&#39;t convert nil into String&quot;
error.  ;Anyone have some advice?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to haml-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Question on how to display blocks in Haml? Getting string and nil errors
country flaguser name
United States
2007-09-02 11:31:44
Here's how I'd do it:

- flash.each do |name, msg|
  %div{:id => "flash_#"}= msg

Or, if you want to use content_tag, you might as well make
it a helper:

def flash_display
  flash.each do |name, msg|
    open :div, msg, :id => "flash_#"
  end
end

Then put in your template:

- flash_display

Malko wrote:
> Hello All,
>
> First off, I love haml/sass and it's changing the way I
work for the
> better, but I'm having some problems wrapping my head
around
> something.
>
>           <% flash.each do |name, msg| %>
> 		        <%= content_tag :div, msg, :id =>
"flash_#" %>
> 		      <% end %>
>
> Take that for example, I can't quite figure out how to
make that
> display correctly without getting a "can't convert
nil into String"
> error.  Anyone have some advice?
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )