【问题标题】:SyntaxError in UsersController#index [closed]UsersController#index 中的 SyntaxError [关闭]
【发布时间】:2015-01-04 05:03:19
【问题描述】:

语法错误,意外的输入结束,期待keyword_end

- if flash.present?
- flash.each do |type, message|
%strong #{type.titleize}:
=message

【问题讨论】:

    标签: html ruby-on-rails ruby haml


    【解决方案1】:

    @mina HAML 对空格很敏感。因此,if 块中的代码必须在下一行缩进 1 个制表符,例如:

    - if flash.present?
      - flash.each do |type, message| 
        %strong 
          = type.titleize + ":" 
        = message
    

    - 符号用于 ruby​​ 代码评估等 = 符号用于在浏览器上显示代码的输出。

    欲了解更多信息,请参阅haml documentation

    【讨论】:

      【解决方案2】:

      你是这样写的?

      - if flash.present?
        - flash.each do |type, message| 
          %strong 
            = type.titleize + ":" 
          = message
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-03-02
        • 2017-03-14
        • 1970-01-01
        • 1970-01-01
        • 2012-09-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多