Anything that's not parsed as some sort of Haml command is literal text. 
So, for your purposes, you could do:

%h2
  by
  = @book.authors.map{|a| a.name}.join(", ")

Alternately, if you're using trunk, you can embed the Ruby directly into 
the text like you would a Ruby string with the "==" command:

%h2
  == by [EMAIL PROTECTED]|a| a.name}.join(", ")}

A cleaner way to do this might be to define a helper method and use that.

# In controller_name_helper.rb

def author_names
  @book.authors.map{|a| a.name}.join(", ")
end

-# In controller_name.haml
%h2
  == by #{author_names}

There is no way to suppress a newline in Haml. There's no need to... if 
you need to use script that shouldn't output, simply use the "-" 
character, and it won't create a newline. For example,

%ul
  - 3.times do |i|
    %li= i

Hope that helps,

- Nathan

wolfego wrote:
> I am having trouble understanding how to combine literal text ("by" in
> the example below) with the result of a ruby expression.  How would I
> write the rhtml listed below as haml?
>
> <h2>by <%= @book.authors.map{|a| a.name}.join(", ") %></h2>
>
> expected output
>
> by John Doe, Jane Doe
>
>
> Also how do I suppress a new line (  -%> ) as in the following rhtml
> in haml?
>
> <% 3.times do -%>
>
> Thanks,
> Bernie
>   

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