加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

Rails 3中的HAML仅生成doctype html

发布时间:2020-12-14 18:29:40 所属栏目:资源 来源:网络整理
导读:嘿伙计们我遇到了一个问题: 如果使用这样的东西: !!! XML!!!%html %head %title Myspace %body %h1 I am the international space station %p Sign my guestbook 我只将此作为来源: !DOCTYPE htmlhtml head titleMyspace/title /head body h1I am the int
嘿伙计们我遇到了一个问题:

如果使用这样的东西:

!!! 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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读