user6052428
user6052428

Reputation:

Haml produces "{}" text on webpage

I am trying to convert from application.html.erb to application.haml and I get one small annoying problem being "{}" in top left corner.

problem

My code looks like this:

  %body
    = render 'shared/header'
    .container
      = flash.each do |message_type, message|
        .alert{class: "alert-#{message_type}"}= message
        -# = content_tag :div, message, class: "alert alert-#{message_type}"
      = yield
      = render 'shared/footer'

Commented out line is a second way to create div, but it produces same error.

HTML before conversion looked like this:

  <body>
    <%= render 'shared/header' %>
    <div class="container">
      <% flash.each do |message_type, message| %>
          <%= content_tag(:div, message, class: "alert alert-#{message_type}") %>
      <% end %>
      <%= yield %>
      <%= render 'shared/footer' %>
    </div>
  </body>

What's wrong with that? How do I fix it?

Upvotes: 0

Views: 49

Answers (1)

Simple Lime
Simple Lime

Reputation: 11035

It looks like you're outputting the return value of your flash.each loop

= flash.each do |message_type, message|

don't write in haml, but after a quick google it looks like maybe use

- flash.each do |message_type, message|

Upvotes: 1

Related Questions