将 haml 标签放在 link_to 助手中 [英] put haml tags inside link_to helper

查看:19
本文介绍了将 haml 标签放在 link_to 助手中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 HAML 中的 link_to 助手中添加 html 内容?

is it possible to add html-content inside a link_to helper in HAML?

我试过了,但我得到的只是一个语法错误:

i tried this, but all i get is a syntax error:

= link_to "Other page", "path/to/page.html"
    %span.icon Arrow

预期输出:

<a href="path/to/page.html">Other Page<span class="icon">Arrow</span></a>

推荐答案

你应该使用块

= link_to "path/to/page.html" do
  Other page
  %span.icon Arrow

这篇关于将 haml 标签放在 link_to 助手中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆