Last active
December 18, 2015 13:29
-
-
Save iulianpw/5789832 to your computer and use it in GitHub Desktop.
sinatra partials
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 PartialPartials | |
ENV_PATHS = %w[ REQUEST_PATH PATH_INFO REQUEST_URI ] | |
def spoof_request( uri, headers=nil ) | |
new_env = env.dup | |
ENV_PATHS.each{ |k| new_env[k] = uri.to_s } | |
new_env.merge!(headers) if headers | |
call( new_env ).last.join | |
end | |
def partial( page, variables={} ) | |
erb page, {layout:false}, variables | |
end | |
end | |
helpers PartialPartials |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment