1

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

%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" 

任何想法将不胜感激!

4

2 回答 2

1

您需要缩进一次渲染

%body
  = render :partial => "landing/landingmenu" 
  - if devise_controller?
    #login
      .span4.offset4  
        = yield
      = render :partial => "landing/footer" 
  - else
    = yield
    = render :partial => "landing/footer" 
于 2013-05-10T18:45:41.590 回答
0

您可以在末尾添加页脚:

%body
  = render :partial => "landing/landingmenu" 
  - if devise_controller?
    #login
      .span4.offset4  
        = yield
  - else
    = yield
  = render :partial => "landing/footer"
    .footer
于 2013-05-10T18:50:05.373 回答