Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save leandrosilva/175335 to your computer and use it in GitHub Desktop.
Save leandrosilva/175335 to your computer and use it in GitHub Desktop.
ApplicationHelper with render a partial method
# 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