Created
August 26, 2009 05:05
-
-
Save leandrosilva/175335 to your computer and use it in GitHub Desktop.
ApplicationHelper with render a partial method
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
# Methods added to this helper will be available to all templates in the application. | |
module ApplicationHelper | |
# Helper to render a partial with or without a block. | |
def render_a_partial(partial_name, options = {}, &block) | |
if block_given? | |
options.merge!(:body => capture(&block)) | |
concat(render(:partial => partial_name, :locals => options), block.binding) | |
else | |
render(:partial => partial_name, :locals => options) | |
end | |
end | |
def render_content_panel(title, options = {}, &block) | |
render_a_partial('layouts/content_panel', options.merge(:title => title), &block) | |
end | |
def render_sidebar_menu(title, options = {}) | |
render_a_partial('layouts/sidebar_menu', options.merge(:title => title)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment