Skip to content

Instantly share code, notes, and snippets.

@iulianpw
Last active December 18, 2015 13:29
Show Gist options
  • Save iulianpw/5789832 to your computer and use it in GitHub Desktop.
Save iulianpw/5789832 to your computer and use it in GitHub Desktop.
sinatra partials
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