如何创建:
<p>
I would like to make a <a href="foo.html">link</a> in my Rails app.
</p>
与HAML?
答案 0 :(得分:23)
1
%p
I would like to make a
%a
link
in my Rails app.
2
%p
I would like to make a <a href="#">link</a> in my Rails app.
答案 1 :(得分:15)
“纯粹的”HAML方式:
%p
I would like to make a
%a{:href => "foo.html"} link
in my Rails app.
使用Rails link_to
帮助程序:
%p
I would like to make a
=link_to "link", "foo.html"
in my Rails app.
答案 2 :(得分:6)
我建议阅读Chris Eppstein的帖子"Haml Sucks for Content",并使用Markdown或Textile之类的东西来处理内联标记。我是Haml的忠实粉丝,用于文档结构,段落中的简单链接很简单,但是Haml开始失控很快。
答案 3 :(得分:4)
如果你知道你的路线,那么你可以这样做:
#{}
非常简单。只需用SELECT Name, AVG(Salary)
FROM SampleData
GROUP BY Name
包装Ruby语法。