Created
January 14, 2010 11:38
-
-
Save joshnesbitt/277095 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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