html - Rails 3 中的 HAML 仅生成 doctype html

标签 html ruby-on-rails ruby xhtml haml

我遇到了一个问题:

如果使用这样的东西:

!!! XML
!!!
%html
  %head
    %title Myspace
  %body
    %h1 I am the international space station
    %p Sign my guestbook

我只得到这个作为来源:

<!DOCTYPE html>
<html>
  <head>
    <title>Myspace</title>
  </head>
  <body>

    <h1>I am the international space station</h1>
    <p>Sign my guestbook</p>
  </body>
</html>

最佳答案

根据HAML documentation , 除了使用 HTML5 的 Rails 3 之外,XHTML 是默认的 DOCTYPE。您可以将 :format 选项设置为覆盖。

config/environment.rb 中:

Haml::Template.options[:format] = :xhtml

关于html - Rails 3 中的 HAML 仅生成 doctype html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4798650/

相关文章:

ruby - 添加黑盒库以进行 Pry 调试

javascript - onFinish 执行时加载 jQuery 事件

ruby-on-rails - 安装ssl证书的问题

ruby-on-rails - rails : getting errors for "no route matches" on paths I don't link to anywhere

ruby - 为什么 aws-sdk-ruby 在初始化时连接到 '169.254.169.254'?

ruby - 具有自定义 IP 的域上的 HTTP 请求

html - 在 Bootstrap 中,为什么无效反馈类会增加输入的宽度?

html - checked 属性值在 HTML 中真的是可选的吗?

javascript - AngularJS - 更改指令的范围

ruby-on-rails - sidekiq队列的优先级