win*_*ons 3 ruby haml ruby-on-rails
我的模板之一中有以下 haml 代码:
%b= t ('activerecord.attributes.exercise.title') + ':'
Run Code Online (Sandbox Code Playgroud)
有没有更优雅的方法来实现这一目标?最好是oneliner,没有括号。
该解决方案我喜欢用是Haml的公司surround,succeed和precede助手:
= surround '(', ')' do
= link_to 'available here', foo_path
= precede '*' do
= link_to 'source', foo_path
= succeed ':' do
= link_to 'foo', foo_path
Text following link
Run Code Online (Sandbox Code Playgroud)
然后它只是在助手之前键入/粘贴一行并缩进助手。
| 归档时间: |
|
| 查看次数: |
996 次 |
| 最近记录: |