Ruby on rails haml中的div title语法,并在其中包含ruby变量

Ruby on rails haml中的div title语法,并在其中包含ruby变量,ruby-on-rails,ruby,ruby-on-rails-3,haml,Ruby On Rails,Ruby,Ruby On Rails 3,Haml,我无法将HTML语法转换为HAML 我知道类可以简单地表示为: .class-name 但是,我想将以下语法转换为HAML,并在标题中加入一个变量: <div title="My title" class="my-text">This is my title</div> 在haml中,您使用#someid.someclass{:custom\u attr=>“something”}:如果需要动态定义,costum_attr也可以是类或id。尝试以下操作: .my-te

我无法将HTML语法转换为HAML

我知道
类可以简单地表示为:

.class-name
但是,我想将以下语法转换为HAML,并在标题中加入一个变量:

<div title="My title" class="my-text">This is my title</div>
在haml中,您使用
#someid.someclass{:custom\u attr=>“something”}
<代码>:如果需要动态定义,costum_attr也可以是类或id。

尝试以下操作:

.my-text{:title => 'My title'} This is my title
或其他语法:

.my-text(title = 'My title') This is my title
.my-text{:title => 'My title'} This is my title
.my-text(title = 'My title') This is my title