You could put something like this in you application helper; based on
the condition, it will wrap what's in the block with your anchor tags.
The key is concating something to the block binding.
def link_if(condition, &proc)
if condition
start_anchor = '<a href="#"
onclick="Effect.toggle('edit_project_name', 'appear', {duration: .5});
return false;">'
end_anchor = '</a>'
concat(start_anchor, proc.binding)
yield
concat(end_anchor, proc.binding)
else
yield
end
end
You should try to take a look at the "Show Source" in the Rails RDocs. While it can sometimes seem like you're falling down a rabbit-hole as little 3-5 line methods call other methods which call still others, you can open up the source file and browse through it. Most of the code is quite well written and it's a great way to learn more about Ruby.