header.clearfix{:role => "banner"}
%h1.logo
%span.company> Cerner
Care
%h2.application-name Welcome to the BigData application suite!
%ul.button-bar
%li
%a{:href => "Logout"} Log Out
%li
%a{:href => "http://www.google.com", :target => "_blank"} Help
%span.username
-unless current_user.nil?
#{current_user.display_name}
%header.context.clearfix{:role => "banner"}
%nav.navigation-bar.clearfix{:role => "navigation"}
%h3.reader-details Account Management Tools
%a.home{:href => root_path, :role => "link", :title => "Home"}Home
%em
%a{:href => "dsonboarding/index", :role => "link"} Data Source Onboarding
%a{:href => "otherapp/index", :role => "link"} Some Other Application
我想在显示用户名之前验证用户名是否为null,haml给出了上述代码的语法错误。如果我做错了,请告诉我?
答案 0 :(得分:1)
为了呈现ruby代码的输出,您需要使用'='。
-unless current_user.nil?
=current_user.display_name
除非异常发生在另一条线上。
我发现他们的tutorial非常有帮助。