-1
    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

我想在显示用户名之前验证用户名是否为空,而 haml 给我上述代码的语法错误。如果我做错了什么,请告诉我?

4

1 回答 1

1

为了呈现 ruby​​ 代码的输出,您需要使用“=”。

-unless current_user.nil?  
  =current_user.display_name

除非异常发生在不同的行上。

我发现他们的教程很有帮助。

于 2013-02-06T17:11:57.250 回答