Created
December 11, 2011 07:45
-
-
Save nirix/1459168 to your computer and use it in GitHub Desktop.
Partials in Sinatra
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
# | |
# Sinatra Partials | |
# Copyright (C) 2011 Jack Polgar | |
# | |
# @copyright Jack Polgar 2011 | |
# @license New BSD License | |
# @example: | |
# render_partial 'articles/article', :article => article | |
# | |
helpers do | |
def render_partial(template, args = {}) | |
template_array = template.to_s.split('/') | |
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}" | |
erb(template.to_sym, :locals => args, :layout => false) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment