2011-03-03 83 views
3

我試圖在HAML中幹掉一些代碼,但似乎偶然發現了一個空白錯誤,我不能完全包住我的頭。

我把標題和左邊的導航代碼放到了layouts文件夾中各自的文件中。

在普通視圖文件,我把這個頂部:

= render 'layouts/header' 
    = render 'layouts/left_navigation' 
/center content column 
    .centerContent.left.phm.rbm 
    /start main center section 
    /and the rest of the code goes below here 

header文件,我有:

/ main container area 
#maincontainer 
/main content 
    #maincontent.mhauto 

而在left navigation文件,我有:

/ left navigation column 
#leftNav.leftNav.left 
/a bunch of code goes in here 
/end left navigation column 

現在,我預計這相當於:

/ main container area 
#maincontainer 
/main content 
    #maincontent.mhauto 
    /left navigation column 
    #leftNav.leftNav.left 
    /a bunch of code goes in here 
    /end left navigation column 
    /center content column 
    .centerContent.left.phm.rbm 
    /start main center section 
    /and the rest of the code goes below here 

但無論出於何種原因,它不能正常工作,而是在指向文件的最後一行時給我這個語法錯誤syntax error, unexpected keyword_ensure, expecting $end。我究竟做錯了什麼?這是我第一次使用HAML,所以這對我來說很困難。

順便說一句,它在我開始幹代碼之前工作得很好,所以這對我來說似乎是一個空白的東西。

回答

6

你有一個嵌套在另一個渲染渲染..我認爲是這個問題:

= render 'layouts/header' 
= render 'layouts/left_navigation' 
/center content column 
.centerContent.left.phm.rbm 
/start main center section 
/and the rest of the code goes below here 
+0

但我怎麼會告訴HAML,我想'離開navigation'被嵌套在標題中'#maincontent'標籤沒有縮進第二個渲染? – iwasrobbed

+0

如果您想在報頭中使用left_navigation,只需在報頭部分內部將其渲染即可。如果你不想讓它始終呈現,那麼你應該使用content_for:header –

相關問題