
Written January 21, 2008. Tagged Ruby, Ruby on Rails, Haml.
I've previously blogged a simple alternative to the Haml succeed helper.
Today I wanted to put a link in parentheses. There is a surround helper, but that syntax isn't pretty.
This is what I do instead:
%li
=h item.name
= "(%s)" % link_to_remote("x", item, :method => :delete)The code
"(%s)" % "foo"in Ruby is short for
format("(%s)", "foo")or
sprintf("(%s)", "foo")and will simply return
(foo)
.