2012-03-21 64 views
6

我決定嘗試苗條模板引擎,但我有奇怪的錯誤。Slim SyntaxError

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'

的意見/認證/ 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 

的意見/佈局/ 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 

我找不出這個錯誤的原因。看起來苗條的解析器試圖解析已經生成的html。但爲什麼?我的錯誤在哪裏?

回答

2

問題已解決。當我重新啓動我的IDE(RubyMine)時,我看到,由於某種原因,文件.html.slim包含來自舊.html.erb的文本。所以,也許這只是一些類似於一個錯誤的一種歧義。

+0

你能解釋一下你發現了多少?我正在經歷同樣的錯誤,它似乎是間歇性的,並且與我的本地環境隔離。謝謝! – 2017-04-13 14:49:32