简体   繁体   English

Flash 消息语法错误,意外的输入结束,期待“结束”

[英]Flash Messages syntax error, unexpected end-of-input, expecting `end'

i use haml and i want to use flash messsages but i have a syntax error, when create the partial _messages.html.haml and rendering in the devise.html.haml i have this error: i use haml and i want to use flash messsages but i have a syntax error, when create the partial _messages.html.haml and rendering in the devise.html.haml i have this error:

ActionView::SyntaxErrorInTemplate in Devise::SessionsController#new Devise::SessionsController#new 中的 ActionView::SyntaxErrorInTemplate

Encountered a syntax error while rendering template: check - flash.each do |name, msg|渲染模板时遇到语法错误:检查 - flash.each do |name, msg| - if msg.is_a?(String) %br %div{:class => "alert alert-#{name.to_s == 'notice'? 'success': 'danger'}"} %button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"} × = content_tag:div, msg, :id => "flash_#{name}" - 如果 msg.is_a?(String) %br %div{:class => "alert alert-#{name.to_s == 'notice'?'success': 'danger'}"} %button.close{"aria -hidden" => "true", "data-dismiss" => "alert", :type => "button"} × = content_tag:div, msg, :id => "flash_#{name}"

Extracted source (around line #8):提取的源代码(第 8 行附近):

    6 = content_tag :div, msg, :id => "flash_#{name}"

Rails.root: /organizator Application Trace | Rails.root: /organizator 应用程序跟踪 | Framework Trace |框架跟踪 | Full Trace app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end'完整跟踪 app/views/layouts/_messages.html.haml:8:语法错误,意外的输入结束,预期end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting结束'

app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end' app/views/layouts/_messages.html.haml:8:语法错误,意外的输入结束,预期end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting结束'

app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end' app/views/layouts/_messages.html.haml:8:语法错误,意外的输入结束,预期end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting结束'

app/views/layouts/devise.html.haml:13应用程序/视图/布局/设计.html.haml:13

Exception Causes SyntaxError: /organizator/app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting `end'异常原因 SyntaxError: /organizator/app/views/layouts/_messages.html.haml:8: 语法错误,意外的输入结束,期待“结束”

in the terminal i have this:在终端我有这个:

ActionView::SyntaxErrorInTemplate (Encountered a syntax error while rendering template: check - flash.each do |name, msg| ActionView::SyntaxErrorInTemplate(渲染模板时遇到语法错误:检查 - flash.each do |name, msg|

  • if msg.is_a?(String) %br %div{:class => "alert alert-#{name.to_s == 'notice'? 'success': 'danger'}"} %button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"} × = content_tag:div, msg, :id => "flash_#{name}" ): 1: - flash.each do |name, msg| if msg.is_a?(String) %br %div{:class => "alert alert-#{name.to_s == 'notice'?'success': 'danger'}"} %button.close{"aria- hidden" => "true", "data-dismiss" => "alert", :type => "button"} × = content_tag:div, msg, :id => "flash_#{name}" ): 1: - flash.each 做|名称,味精| 2: - if msg.is_a?(String) 3: %br 4: 2: - 如果 msg.is_a?(String) 3: %br 4:
    %div{:class => "alert alert-#{name.to_s == 'notice'? 'success': 'danger'}"} 5: %button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"} × 6: = content_tag:div, msg, :id => "flash_#{name}" %div{:class => "alert alert-#{name.to_s == 'notice'?'success': 'danger'}"} 5: %button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"} × 6: = content_tag:div, msg, :id => "flash_#{name}"

app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting end' app/views/layouts/devise.html.haml:13 app/views/layouts/_messages.html.haml:8:语法错误,意外的输入结束,预期end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting结束'app/views/layouts/_messages.html.haml:8:语法错误,意外的输入结束,期待end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting结束'app/views/layouts/_messages.html.haml:8:语法错误,意外的输入结束,期待end' app/views/layouts/_messages.html.haml:8: syntax error, unexpected end-of-input, expecting结束' app/views/layouts/devise.html.haml:13

My devise template devise.html.haml app/views/layouts/devise.html.haml我的 devise 模板 devise.html.haml app/views/layouts/devise.ZFC35FDC.80D5FCC69D2E3E369

!!!
%html
    %head
        %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
        %title Tasker
        = csrf_meta_tags
        = csp_meta_tag
        = javascript_pack_tag 'application', 'data-turbolinks-track': 'reload'
        = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
    %body
        .container
            .main-flash-messages
                = render 'layouts/messages'
        .fullscreen
            .container
                = yield

My partial _messages.html.haml app/views/layouts/_messages.html.haml我的部分 _messages.html.haml app/views/layouts/_messages.html.haml

- flash.each do |name, msg|
    - if msg.is_a?(String)
    %br
    %div{:class => "alert alert-#{name.to_s == 'notice' ? 'success' : 'danger'}"}
        %button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"} ×
        = content_tag :div, msg, :id => "flash_#{name}"

I tryed to solve this reading the documentation of haml but i don't know what is wrong.我试图通过阅读 haml 的文档来解决这个问题,但我不知道出了什么问题。 Regards.问候。

I am not familiar with HAML but I expect that the content that depends on the if condition needs to be indented and would therefore try:我不熟悉 HAML,但我希望取决于if条件的内容需要缩进,因此会尝试:

- flash.each do |name, msg|
  - if msg.is_a?(String)
    %br
    %div{:class => "alert alert-#{name.to_s == 'notice' ? 'success' : 'danger'}"}
      %button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"} ×
      = content_tag :div, msg, :id => "flash_#{name}"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 语法错误,输入意外终止,应使用keyword_end - syntax error, unexpected end-of-input, expecting keyword_end 语法错误:意外的keyword_ensure,预期输入结束 - Syntax Error: unexpected keyword_ensure, expecting end-of-input 非常基本:“语法错误,意外的'=',期望输入结束” - Very basic: “syntax error, unexpected '=', expecting end-of-input” Rails 4 - 语法错误,意外的tIDENTIFIER,期望输入结束 - Rails 4 - syntax error, unexpected tIDENTIFIER, expecting end-of-input Gemfile:22: 语法错误,意外的 tIDENTIFIER,期望输入结束 - Gemfile:22: syntax error, unexpected tIDENTIFIER, expecting end-of-input Ruby on Rails 语法错误,意外的输入结束,期待关键字结束 ^ - Ruby on Rails syntax error, unexpected end-of-input, expecting keyword_end end ^ 语法错误,意外结束,期望输入结束,但我认为它有正确的结束编号 - Syntax error, unexpected end, expecting end-of-input, though I think it has right end number 语法错误“语法错误,意外的输入结束,期望关键字结束(SyntaxError)” - Syntax error “syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)” Rails的Heroku错误:语法错误,意外的keyword_end,期望输入结束 - Heroku error with Rails: syntax error, unexpected keyword_end, expecting end-of-input 语法错误,意外的输入结束,需要keyword_end (SyntaxError) Address_book - syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError) Address_book
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM