HAML视图中存在大量语法错误(使用狂欢引擎)



我有一个简单的HAML视图,admin.html.haml:

!!!
%html{:xmlns => "http://www.w3.org/1999/xhtml"}
  %head{"data-hook" => "admin_inside_head"}

(视图相当大,为了清晰起见,我删除了大部分)

http://localhost:3000/admin我得到:

SyntaxError in Spree/admin/overview#index
Showing /Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml where line #2 raised:
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:2: syntax error, unexpected '=', expecting ')'
...ut.attributes({}, nil, :xmlns => "http://www.w3.org/1999/...
...                               ^
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:2: syntax error, unexpected ')', expecting '}'
..."http://www.w3.org/1999/xhtml")}>n  <head#{_hamlout.adjust_...
...                               ^
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: syntax error, unexpected '=', expecting ')'
...tributes({}, nil, "data-hook" =&gt; "admin_inside_head")}></...
...                               ^
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: syntax error, unexpected ')', expecting '}'
...ook" =&gt; "admin_inside_head")}></head>n</html>n", -1, fa...
...                               ^
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: unknown regexp options - htl
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: syntax error, unexpected $undefined
...nside_head")}></head>n</html>n", -1, false);::Haml::Util.h...
...                               ^
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: unterminated string meets end of file
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: syntax error, unexpected $end, expecting '}'
Extracted source (around line #2):
1: !!!
2: %html{:xmlns =&gt; "http://www.w3.org/1999/xhtml"}
3:   %head{"data-hook" =&gt; "admin_inside_head"}
Trace of template inclusion: /Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml

haml-gem加载正确(扰乱了haml视图缩进,我得到了一个haml::SyntaxError),在将spread视图切换到haml之前,它在erb视图中运行良好。

有人能建议检查什么以解决错误吗?

我发现了问题:

Spree使用了与HAML不兼容的污损(见此处)。

解决方案是在特定于环境的配置文件(development.rb、production.rb等)中禁用污损。添加此:

  # Disable deface
  config.deface.enabled = false 

最新更新