gpt4 book ai didi

ruby - Hanami link_to 助手只呈现最后一个元素

转载 作者:数据小太阳 更新时间:2023-10-29 07:12:39 24 4
gpt4 key购买 nike

我是 Hanami World 的新人。我已经写了这段代码:

module Web::Views::Home
class Index
include Web::View
include Hanami::Helpers::HtmlHelper

def title
html.header do
h1 'Test search engine', id: 'title'
hr
div(id: 'test') do
link_to('Home', "/", class: 'mnu_orizontal')
link_to('About', "/", class: 'mnu_orizontal')
end
end
end
end
end

我在模板上调用了 title 方法。html 结果是:

<header>
<h1 id="title">Test search engine</h1>
<hr>
<div id="test">
<a class="mnu_orizontal" href="/">About</a>
</div>
</header>

为什么第二个链接覆盖第一个?我的错误在哪里?

感谢您的任何回复。

最佳答案

这是expected behaviour对于当前版本的 hanami/helpers (v0.3.0)。

正如 jodosha 在上面链接的问题上写的那样:

After a deeper looking at this issue, it isn't a bug. link_to doesn't work like the other HTML builder methods. That means you can avoid to concat tags.

下一个版本 (v0.4.0) 将允许连接 link_to,参见 PR .

所以这不是你的错,但我认为 documentation不同步,它已经显示了 new version .

希望对您有所帮助!再见。

关于ruby - Hanami link_to 助手只呈现最后一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37526115/

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