1

In erb we can have

<%= @user.name %>, <%= @user.email %>

to put name and email in one line both on the resulting page and in the code.

What is the best way to do the same with Haml?

=@user.name << ', ' << @user.email

and

="#{@user.name}, #{@user.email}"

both work, but lack the Haml beauty. What would you recommend?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303

1 Answers1

3

You can do straight interpolation:

%p #{@user.name}, #{@user.email}
Alex Peachey
  • 4,606
  • 22
  • 18