【问题标题】:Rails tutorial hamlRails 教程 haml
【发布时间】:2015-03-27 18:34:39
【问题描述】:

我决定将 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 haml railstutorial.org


    【解决方案1】:

    要获得您想要的结果,请从 HTML 中删除换行符:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多