-1

如何在 HAML 中编写此 ERB 代码:

<head>
  <meta charset="utf-8">
  <title><%= title %></title>
  <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
  <%== meta_data_tags %>
  <%= favicon_link_tag image_path('favicon.ico') %>
  <link rel="apple-touch-icon" href="apple-touch-icon.png">
  <link rel="apple-touch-icon" sizes="72x72" href="apple-touch-icon-72x72.png">
  <link rel="apple-touch-icon" sizes="114x114" href="apple-touch-icon-114x114.png">
  <%= stylesheet_link_tag 'store/all', :media => 'screen' %>
  <%= csrf_meta_tags %>
  <%= javascript_include_tag 'store/all' %>
  <!--[if lt IE 9]>
    <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6/html5shiv.min.js"></script>
  <![endif]-->
  <%= render "spree/shared/routes" %>
  <%= yield :head %>
</head>

对这个特别感兴趣

<%== meta_data_tags %>

代码片段。

4

2 回答 2

2

我找到了我的问题的答案:

= raw(meta_data_tags)

<%== %>是一样的<%= raw() %>。它只是实现相同结果的快速帮手。

谢谢大家的帮助。=)

于 2013-10-21T19:49:04.860 回答
1

在 Erubis(Rails 使用)中,<%== ... %>语法转义了表达式的结果。Haml 具有类似的功能,使用&=.

因此,Haml 版本<%== meta_data_tags %>可能看起来像:

&= meta_data_tags
于 2013-10-21T17:40:23.663 回答