2012-04-20 57 views
1

我有这个HAML页面渲染:HAML - 为什么我的HAML的文本都显示在上面一行,尽管对代码的差异部分

-content_for :primary_content do 

    Hmmm 
    %strong{:class => "code", :id => "message"} Hello Alex! 

    .container-fluid 
    .row-fluid 
     .span1 Hello 1 
     .span4 Hello 4 
     .span4 Hello 4 again 
     .span3 Hello 3 

    %strong{:class => "code"} End of page! 

    .container-fluid 
    .row-fluid 
     .span9 My Disclosures o ye! 
     .span3 This will be the side area 

     // Ok....what is in home? 
     // The two divs.... 

    -content_for :primary_content do 
    -if signed_in? 
     // =render "sidebar/common/primary_navigation" 
     // If signed in, show the options for 
     // 1) Logout | My Profile 
     // 2) Create disclosure | show disclosures 
     Signed in 
    -else 
     // =render "devise/sessions/form" 
     NOT Signed in 

出于某种原因,它呈现Not signed in Hmmm Hello Alex!的顶线和然后它下面的一切。

我很困惑,因为“未登录”位于页面底部,而“嗯,你好亚历克斯”在最上面。但由于某种原因,它在屏幕上一起渲染。任何想法为什么?

谢谢!

回答

2

首先我想指出,你似乎有一个嵌套的content_for,这可能是一个问题。

其次,我建议分开两个content_for块并为登录区域创建另一个。像

- content_for :login do 
    -if signed_in? 
    // =render "sidebar/common/primary_navigation" 
    // If signed in, show the options for 
    // 1) Logout | My Profile 
    // 2) Create disclosure | show disclosures 
    Signed in 
    -else 
    // =render "devise/sessions/form" 
    NOT Signed in 

东西然后把

yield :login 

yield :primary_content 

某处后分离关注并使其所以你不要有任何内容踩着别人的脚趾。

相关问题