HAML将部分放在前面的div中

时间:2013-05-10 16:36:45

标签: html ruby-on-rails haml

我正在使用我的网站着陆区的布局,并且我正在使用devise_controller?添加#login&的方法.span.offset4告诉Devise视图移动到中间并设置背景颜色。

%body
  = render :partial => "landing/landingmenu" 
  - if devise_controller?
    #login
      .span4.offset4  
        = yield
  - else
    = yield
  = render :partial => "landing/footer"

此输出的内容部分位于#login div中,而不是在其外部:

<body>
  <div id="login">
    <div class="span4 offset4">...</div>
    <div class="footer">...</div>
  </div>
</body>

我已经尝试将页脚部分放在if中,如果是这样,并获得相同的错误嵌套HTML输出:

%body
  = render :partial => "landing/landingmenu" 
  - if devise_controller?
    #login
      .span4.offset4  
        = yield
    = render :partial => "landing/footer" 
  - else
    = yield
    = render :partial => "landing/footer" 

任何想法都会非常感激!

2 个答案:

答案 0 :(得分:1)

你需要缩进再渲染一次

%body
  = render :partial => "landing/landingmenu" 
  - if devise_controller?
    #login
      .span4.offset4  
        = yield
      = render :partial => "landing/footer" 
  - else
    = yield
    = render :partial => "landing/footer" 

答案 1 :(得分:0)

您可以在最后添加页脚:

%body
  = render :partial => "landing/landingmenu" 
  - if devise_controller?
    #login
      .span4.offset4  
        = yield
  - else
    = yield
  = render :partial => "landing/footer"
    .footer