2015-06-24 66 views
-4

需要將此HAML代碼轉換爲ERB。當我使用HamltoErb轉換器時出錯。任何幫助將不勝感激。如何將此haml代碼轉換爲erb?

%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. 
+0

你會得到什麼錯誤? –

回答

1

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

轉換返回錯誤:

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

這意味着他不理解在這方面?。首先猜測是將第一行改爲:

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

Ohmygoditworks。

試着把一些東西放在東西之前發佈在這裏

+0

謝謝@ piotr-kruczek剛開始使用Ruby和Rails以後,我意識到我可能已經自滿,但我會確保不要在這裏再問任何問題。再次感謝。 – raybesiga