Skip to content

Instantly share code, notes, and snippets.

@joshnesbitt
Created January 14, 2010 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshnesbitt/277095 to your computer and use it in GitHub Desktop.
Save joshnesbitt/277095 to your computer and use it in GitHub Desktop.
Usage:
With block:
= link_to_facebox "Click here for facebox", "mydiv" do
%p Hello there ted
Without block:
= link_to_facebox "Click here for google", "http://google.com"
module FaceboxHelper
def link_to_facebox(text, location, opts={}, &block)
block_given? ? (facebox_link(text, "##{location}", opts) + facebox_div(location, &block)) : facebox_link(text, location, opts)
end
protected
def facebox_link(text, path, opts={})
link_to text, path, {:rel => "facebox"}.merge!(opts)
end
def facebox_div(id, &block)
content_tag(:div, capture(&block), :id => id, :style => "display:none")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment