HAML语法错误“期待$ end”

时间:2011-03-03 19:38:05

标签: ruby-on-rails haml syntax-error

我试图在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,所以这对我来说非常困惑。

顺便说一句,在我开始编写代码之前它完全没问题,所以这对我来说似乎是一个空白的东西。

1 个答案:

答案 0 :(得分: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
相关问题