gpt4 book ai didi

haml - 同一行上的多个 Haml 元素

转载 作者:行者123 更新时间:2023-12-03 23:20:35 27 4
gpt4 key购买 nike

我希望能够在同一行上有两个 Haml 元素。例如:
%h1 %a{:href => '/'} Professio.
那行不通。我怎样才能让这样的事情在不无聊的情况下工作?

最佳答案

不幸的是,您不能将两个 haml 元素放在同一行上。

您可以通过使用内联 html 元素来实现类似的功能:

%h1 <a href='/'>Lorem ipsum</a>

你为什么不喜欢这种格式?
%h1 
%a{:href => '/'} Professio.

另一种选择是编写特殊的 'helper' 方法(生成 html 链接)。例如,Rails 中的 link_to:
%h1= link_to 'Professio', root_url

关于haml - 同一行上的多个 Haml 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2437168/

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