The cleanest way to do this is to provide a concept that allows any content that you want to capture correctly:
= allowed? do
- capture_haml do
= link_to('New', new_video_path)
In your case, however, why not just write another helper method?
def allowed_link_to(*args, &block)
opts = args.extract_options!
if allowed? args.last
link_to args.push(opts), &block
else
''
end
end
And use it as follows:
= allowed_link_to('New', new_video_path)
Kelly source
share