Rails 教程 haml

Rails tutorial haml

提问人:Jakxna360 提问时间:3/28/2015 更新时间:3/28/2015 访问量:390

问:

我决定将 ruby on rails 教程从 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 在测试期间将其作为一行阅读?

提前感谢您的帮助。

Ruby-on-Rails 哈姆 railstutorial.org

评论


答:

1赞 Mohammad AbuShady 3/28/2015 #1

若要获得所需的结果,请从 HTML 中删除换行符:

= "#{yield :title} | Ruby on Rails Tutorial Sample App"