Rails 教程 haml

Rails tutorial haml

我决定将 rails 上的 ruby 教程从 erb 更改为 haml。我现在遇到这个输出:

     FAIL["test_should_get_home", StaticPagesControllerTest, 0.066385842]
     test_should_get_home#StaticPagesControllerTest (0.07s)
    <Home | Ruby on Rails Tutorial Sample App> expected but was
    <Home
    | Ruby on Rails Tutorial Sample App">..
    Expected 0 to be >= 1.
    test/controllers/static_pages_controller_test.rb:11:in `block in  <class:StaticPagesControllerTest>'

FAIL["test_should_get_about", StaticPagesControllerTest, 0.071358831]
test_should_get_about#StaticPagesControllerTest (0.07s)
    <About | Ruby on Rails Tutorial Sample App> expected but was
    <About
    | Ruby on Rails Tutorial Sample App">..
    Expected 0 to be >= 1.
    test/controllers/static_pages_controller_test.rb:23:in `block in <class:StaticPagesControllerTest>'

FAIL["test_should_get_contact", StaticPagesControllerTest, 0.07536422]
test_should_get_contact#StaticPagesControllerTest (0.08s)
    <Contact | Ruby on Rails Tutorial Sample App> expected but was
    <Contact
    | Ruby on Rails Tutorial Sample App">..
    Expected 0 to be >= 1.
    test/controllers/static_pages_controller_test.rb:29:in `block in <class:StaticPagesControllerTest>'

FAIL["test_should_get_help", StaticPagesControllerTest, 0.08334098]
test_should_get_help#StaticPagesControllerTest (0.08s)
    <Help | Ruby on Rails Tutorial Sample App> expected but was
    <Help
    | Ruby on Rails Tutorial Sample App">..
    Expected 0 to be >= 1.
       test/controllers/static_pages_controller_test.rb:17:in `block in    <class:StaticPagesControllerTest>'

这是 application.rb 文件:

  %html
   %head
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
%title
  = yield(:title)
  | Ruby on Rails Tutorial Sample App
= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags
%body
= yield

所以问题是如何让 haml 在测试期间将其读作一行?

提前感谢您的帮助。

要获得您想要的结果,请删除 HTML:

中的换行符
= "#{yield :title} | Ruby on Rails Tutorial Sample App"