Ruby on rails HAML-为什么我的HAML';s文本全部显示在顶行,尽管在代码的不同部分呈现
我有这个HAML页面:Ruby on rails HAML-为什么我的HAML';s文本全部显示在顶行,尽管在代码的不同部分呈现,ruby-on-rails,ruby,haml,Ruby On Rails,Ruby,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 %stro
-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
由于某些原因,它呈现未登录的,Hmmm Hello Alex代码>在顶行,然后是它下面的所有内容
我很困惑,因为“未登录”在页面底部,而“嗯,你好,亚历克斯”在顶部。但由于某些原因,它会一起呈现在屏幕上。知道为什么吗
谢谢 首先,我想指出,您似乎有一个嵌套的内容,这可能是一个问题
其次,我建议将两个块的内容_分开,并专门为登录区域创建另一个块。差不多
- 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
分离关注点并使之成为现实,这样你就不会有任何内容影响到其他人