lib/brochure/context.rb in brochure-0.2.0 vs lib/brochure/context.rb in brochure-0.3.0
- old
+ new
@@ -8,16 +8,27 @@
context
end
attr_accessor :application, :env
- def initialize(application, env)
+ def initialize(application, env, assigns = {})
self.application = application
self.env = env
+ load_assigns(assigns)
end
+ def load_assigns(assigns)
+ assigns.each do |name, value|
+ instance_variable_set("@#{name}", value)
+ end
+ end
+
def request
@_request ||= Rack::Request.new(env)
+ end
+
+ def h(html)
+ Rack::Utils.escape_html(html)
end
def render(logical_path, locals = {})
if template = @application.find_partial(logical_path)
@application.render_template(template, env, locals)