Skip to content

Instantly share code, notes, and snippets.

@cj
Created February 4, 2012 15:13
Show Gist options
  • Save cj/1738422 to your computer and use it in GitHub Desktop.
Save cj/1738422 to your computer and use it in GitHub Desktop.
module Padrino
module Liquid
module Helpers
def render(engine, data=nil, options={}, locals={}, &block)
ignored_ivs = [
'@default_layout',
'@app',
'@template_cache',
'@env',
'@request',
'@response',
'@params',
'@_response_buffer',
'@route',
'@block_params',
'@_content_type',
'@current_ability',
'@block_params',
'@layout'
]
user_ivs = []
self.instance_variables.to_s.gsub(/(\[|\]|:)/, '').split(', ').each do |key|
user_ivs << key if not ignored_ivs.include? key
end
user_ivs.each do |iv|
locals[iv[1..-1]] = self.instance_variable_get iv
end
super engine, data, options, locals, &block
end
end
def self.registered(app)
app.helpers Helpers
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment