Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何在haml中使用动态链接_Ruby On Rails_Haml - Fatal编程技术网

Ruby on rails 如何在haml中使用动态链接

Ruby on rails 如何在haml中使用动态链接,ruby-on-rails,haml,Ruby On Rails,Haml,我使用的是Haml,标题中包含指向另一个页面的链接,如下所示: .heading = link_to community.community_tag_path(community_tag) do 这最终会产生一个链接 我需要将标题中使用的相同链接嵌入到通用span标记中,如下所示: %span View all Articles 如何使用haml将其用作链接?基本上,我需要与标题中相同的链接来处理span是的,您可以将do块传递给链接u以运行: = link_to community.

我使用的是Haml,标题中包含指向另一个页面的链接,如下所示:

.heading
   = link_to community.community_tag_path(community_tag) do
这最终会产生一个链接

我需要将标题中使用的相同链接嵌入到通用span标记中,如下所示:

%span View all Articles

如何使用haml将其用作链接?基本上,我需要与标题中相同的链接来处理span

是的,您可以将do块传递给链接u以运行:

= link_to community.community_tag_path(community_tag) do
  %span View all Articles
或者,如果希望跨度将链接_环绕到:

%span= link_to "View all Articles", community.community_tag_path(community_tag)
要显示带有社区标记名称的链接,只需执行以下操作:

%span= link_to community_tag.name, community.community_tag_path(community_tag)
以下是一些关于链接到的文档:


在注释之后,要显示“查看所有[community tag's name]文章”之类的链接,您可以执行字符串插值:

"View all #{community_tag.name} articles"

并将此字符串添加为链接的第一个参数。

您可以通过以下方法实现:

.heading    
  = link_to community.community_tag_path(community_tag) do
    %span View all Articles

还可以在字符串内部使用方法。但我更喜欢像过去的评论那样直接使用

%a{href: "#{community.community_tag_path(community_tag)}"} View all Articles

将链接嵌入到链接中?你能更具体地解释一下你想做什么吗?我更新了问题,希望它更有意义。添加动态文本而不是查看所有文章,查看所有xxxx,这是由community_tag.name创建的。如何连接,以便我可以输入带有community tag name的通用副本?如是:“查看所有[社区标签]文章