gmaps / haml代码上的语法错误

时间:2013-06-26 14:13:49

标签: ruby-on-rails-3 haml gmaps4rails

我有这段代码在页面上显示多个地图:

.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

它返回错误“语法错误,意外的keyword_ensure,期待$ end”,但我无法弄清楚这里有什么问题。 better_errors gem显示代码中3“容器_#{counter}”项的错误。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

你有一些不必要的缩进,行 - unless map_visits.blank?(及其后面的行)不应缩进:

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