【问题标题】:how do I add attributes to the html tag in haml?如何在haml中为html标签添加属性?
【发布时间】:2011-06-15 21:32:37
【问题描述】:

为了让我使用 formtastic,看来我需要这个作为我的 html 标记:

 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

我如何在 HAML 中执行此操作?

【问题讨论】:

    标签: haml formtastic


    【解决方案1】:

    与在 Haml 中添加 attributes to any other tag 的方式相同:

    %html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en"}
    

    Haml 实际上有一个built in helper method for these attributes,所以你可以这样做:

    %html{html_attrs}
    

    默认使用“en-US”作为语言,或者传递您要使用的语言字符串:

    %html{html_attrs('en')}
    

    【讨论】:

      猜你喜欢
      • 2020-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-28
      • 1970-01-01
      • 2014-04-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多