The Pug Automatic

surround helper alternative in Haml

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:

= "(%s)" % link_to_remote("x", item, :method => :delete)

The code

"(%s)" % "foo"

in Ruby is short for

format("(%s)", "foo")


sprintf("(%s)", "foo")

and will simply return