Search code examples
ruby-on-rails-3hamlgmaps4rails

Syntaxt error on gmaps/haml code


I have this piece of code to show multiple maps on a page:

.row
  .span12
    - counter = 1
    - @users.each do |user|
      - map_visits = user.visits.to_gmaps4rails
        - unless map_visits.blank?
          .span3
            %div{ id: "container_#{counter}" }
              %div{ id: "map_#{counter}" }
                = gmaps(map_options: { zoom: 6, container_id: "container_#{counter}", id: "map_#{counter}" }, markers: { data: map_visits } )
                - counter += counter

It returns an error "syntax error, unexpected keyword_ensure, expecting $end", but I can't really figure out what's wrong here. The better_errors gem shows the error on the 3 "container_#{counter}" items in the code. Any ideas?


Solution

  • You’ve got some unnecessary indentation, the line - unless map_visits.blank? (and the lines following it) shouldn’t be indented:

    - map_visits = user.visits.to_gmaps4rails
    - unless map_visits.blank?
      .span3
        ...