Slim语法错误

7
我决定尝试使用Slim模板引擎,但是我遇到了奇怪的错误。
ActionView::Template::Error (Unknown line indicator
  app/views/layouts/application.html.slim, Line 1
    <!DOCTYPE html>
    ^
):
  slim (1.1.1) lib/slim/parser.rb:448:in `syntax_error!'

它出现在所有页面上。例如:

Started GET "/" for 127.0.0.1 at 2012-03-21 09:47:49 +0400
Processing by AuthenticationsController#index as HTML
  Authentication Load (0.9ms)  SELECT "authentications".* FROM "authentications" 
  User Load (1.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 17 LIMIT 1
  CACHE (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 17 LIMIT 1
  Rendered authentications/index.html.slim within layouts/application (88.4ms)

我在我的Gemfile中使用了gem 'slim-rails',并且

视图文件views/authentications/index.html.slim:

table
  tr
    th User
    th Provider
    th Uid
  - for authentication in @authentications
    tr
      td = authentication.user_id
      td = authentication.provider
      td = authentication.uid
      td = link_to "Destroy", authentication, :confirm => 'Are you sure?', :method => :delete

views/layouts/application.html.slim:

doctype 5
html
  head
    title gttc
    = stylesheet_link_tag    "application", :media => "all"
    = javascript_include_tag "application"
    = csrf_meta_tags
  body
    p hi!
    = yield 

我无法确定这个错误的原因。看起来 slim 解析器正在尝试解析已经生成的 HTML。但是为什么呢?我的错误在哪里?

1个回答

2
问题解决了。当我重新启动我的IDE(RubyMine)时,我发现,某种原因导致.html.slim文件包含了旧的.html.erb文件的文本。所以可能只是Rubymine中的某种错误。

你能再详细解释一下你发现的情况吗?我也遇到了同样的错误,而且似乎是间歇性的,并且只出现在我的本地环境中。谢谢! - Mike Fleming

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接