gpt4 book ai didi

ruby-on-rails - 带测试的 HAML 换行问题

转载 作者:行者123 更新时间:2023-11-28 21:11:21 25 4
gpt4 key购买 nike

运行 assert_select测试 erb 以生成带有副本的页面标题。 Haml 似乎将复制部分推到一个新行。它在 View 中正确显示,但由于添加了新行,我的测试失败了。


test "should get about" do
get :about
assert_response :success
assert_select "title", "About | Ruby on Rails Tutorial Baby Twitter"
end

我的关于 View :- provide(:title, "About")

应用布局
%title
= yield (:title)
| Title Copy

HTML 输出


<title>
Home
| Title Copy
</title>

应该是
<title>
Home | Title Copy
</title>

最佳答案

在您的应用程序布局更改中:

%title
#{yield(:title)} | Title Copy

在您看来: = provide(:title, 'About')

这将显示正确的 HTML 输出。

关于ruby-on-rails - 带测试的 HAML 换行问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26443222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com