同一行上的多个Haml元素 [英] Multiple Haml Elements on Same Line

查看:81
本文介绍了同一行上的多个Haml元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在同一行上包含两个Haml元素.例如:

I want to be able to have two Haml elements on the same line. For example:

%h1 %a{:href => '/'} Professio.

那是行不通的.我该如何在不感到厌烦的情况下使这种工作正常工作?

That doesn't work. How would I get something like this to work without borking?

推荐答案

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

Unfortunately, you cannot put two haml elements on the same line.

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

You can achieve something similar by using inline html elements:

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

您为什么不喜欢这种格式?

Why don't you like this format?

%h1 
  %a{:href => '/'} Professio.

另一个选择是编写特殊的"helper"方法(生成html链接).例如,Rails中的link_to:

Another option is to write special 'helper' method (that generate an html link). For example, the link_to in Rails:

%h1= link_to 'Professio', root_url

这篇关于同一行上的多个Haml元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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