[英]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:
Devise::SessionsController#new 中的 ActionView::SyntaxErrorInTemplate
渲染模板时遇到语法错误:检查 - flash.each do |name, msg| - 如果 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}"
提取的源代码(第 8 行附近):
6 = content_tag :div, msg, :id => "flash_#{name}"
Rails.root: /organizator 应用程序跟踪 | 框架跟踪 | 完整跟踪 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
结束'
应用程序/视图/布局/设计.html.haml:13
异常原因 SyntaxError: /organizator/app/views/layouts/_messages.html.haml:8: 语法错误,意外的输入结束,期待“结束”
在终端我有这个:
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 做|名称,味精| 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}"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
我的 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
我的部分 _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}"
我试图通过阅读 haml 的文档来解决这个问题,但我不知道出了什么问题。 问候。
我不熟悉 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.