0

当用户在 root_path 上时,我想添加一个 css 类:登陆页面。我正在使用haml。

%body
  ={:class => "landing-page" if current_page?(root_path)}

我收到语法错误,关于这实际上应该如何的任何想法?

更新: 我这样做了,它对我有用:

%body{:class => "normal-page#{current_page?(root_path) ? 'landing-page' : ''}"}
4

1 回答 1

0

尝试这个

-body_class = current_page?(root_path) ? "landing-page" : ""
%body{:class => body_class}
于 2013-06-25T17:57:45.540 回答