0

出于某种原因,当我在 Rails 应用程序中使用部分内容时,我的 HTML 文档树会中断,并且头部元素会溢出 body 元素。我把它归结为一个非常简单的例子:

app/views/layouts/application.html.erb

<!doctype html>
<html>
  <head>
    <%= render :partial => 'shared/head' %>
  </head>
  <body id="test-id">
    <h1>Hello World</h1>
  </body>
</html>

app/views/shared/head.html.erb

<title>Test Title</title>

结果

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head> 
  <body>
    <title>Test Title</title>
    <h1>Hello World</h1>
  </body>
</html>

请注意, id 属性 on 已丢失,并且该元素不在应有的位置。

有没有人见过这样的东西或者可以提供调试提示?

我在跑:

  • OSX 10.8.3
  • 红宝石-1.9.3-p392
  • 导轨 3.2.11 / WEBrick
  • Spree 1.1.4(尽管我已经删除了 Spree 可能影响的任何内容)
4

1 回答 1

0

Turns out I had Deface running in the background which was causing an error which was mangling my <head>.

If anybody is running Spree and sees weird issues with their templating, first look at the Rails logs for Deface errors and check your libxml version. If it's > 2.8.0 you may need to downgrade. More info here.

于 2013-04-30T21:33:03.617 回答