如何将此haml代码转换为erb?

时间:2015-06-24 13:53:02

标签: html ruby-on-rails ruby haml erb

需要将此HAML代码转换为ERB。使用HamltoErb转换器时出错。任何帮助将不胜感激。

%header.main{:class => @full_header ? 'full' : 'basic'}
  .inner
    / Primary navigation
    %nav.main
      %ul
        %li= link_to "Home", root_path, :nav_item => :home
        %li
          = link_to "Our catalogue", catalogue_path, :nav_item => :catalogue, :class => 'noborder'
          %ul
            - for category in Shoppe::ProductCategory.ordered
              %li= link_to category.name, products_path(category.permalink)
        %li= link_to "Why shop with us?", page_path(:why), :nav_item => :why
        %li= link_to "FAQs", page_path(:faqs), :nav_item => :faqs
        %li= link_to "Get in touch", page_path(:contact), :nav_item => :contact
      %h1= link_to Shoppe.settings.store_name, root_path

    - if @full_header
      %h2 Welcome to our <em>shoppe</em>.
      %p.intro Check out our lovely products on this page and then you can buy them through the website with just a few clicks using our supremely simple ordering system.

  - if @full_header
    .bar
      .inner
        %p.call Call us today on <b>01202 901 101</b> if you have any questions.
        %p.offer <b>This week only!</b> FREE next day shipping on all orders over &pound;30.

1 个答案:

答案 0 :(得分:1)

首先谷歌搜索转换器:https://haml2erb.org/

转换返回错误:

(line 1, column 37):
unexpected "?"
expecting space, "(" or "["

意思是他在那个背景下不理解?。首先猜测是将第一行改为:

%header.main{:class => (@full_header ? 'full' : 'basic')}

Ohmygoditworks。

在发布之前尝试先付出一些努力