[英]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.