Created
September 9, 2010 20:44
-
-
Save jaz303/572538 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 SomeHelper | |
# | |
# Block Menu | |
def block_menu(&block) | |
BlockMenuBuilder.new(self).render(&block) | |
end | |
class BlockMenuBuilder | |
def initialize(template) | |
@template = template | |
end | |
def render(&block) | |
html = "<div class='block-menu'>\n" | |
html << @template.capture(self, &block) | |
html << "</div>\n" | |
html.html_safe | |
end | |
def item(icon, title, url = false, &block) | |
html = "<a class='#{url ? '' : 'inactive'}' href='#{url ? url : '#'}'>\n" | |
html << " <span class='icon' style='#{@template.background_icon(icon)}'></span>\n" | |
html << " <span class='title'>#{@template.h(title)}</span>\n" | |
html << " <span class='caption'>\n" | |
html << " #{@template.capture(&block)}" if block_given? | |
html << " </span>" | |
html << "</a>" | |
html.html_safe | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment