Sha256: ed897338ef4d2f21ed646814285347ff220b2a4bcfc3fb805854e9b0ac5c2868
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
require File.dirname(__FILE__)+'/mixins/erubis_capture_mixin' require File.dirname(__FILE__)+'/mixins/javascript_mixin' module Merb # the ViewContext is really # just an empty container for us to fill with instance # variables from the controller, include helpers into # and then use as the context object passed to Erubis # when evaluating the templates. class ViewContext include Merb::ErubisCaptureMixin include Merb::JavascriptMixin def initialize(controller) @controller = controller (@controller.instance_variables - %w[@cookies @session @headers @params @env @in @status @root @method @request @fingerprint_before @controller @k]).each do |ivar| self.instance_variable_set(ivar, @controller.instance_variable_get(ivar)) end begin self.class.class_eval("include Merb::#{@controller.class.name}Helper") rescue NameError MERB_LOGGER.info("Missing Helper: Merb::#{@controller.class.name}Helper") end end # accessor for the view. refers to the current @controller object def controller @controller end # catch any method calls that the controller responds to # and delegate them back to the controller. def method_missing(sym, *args, &blk) if @controller.respond_to? sym @controller.send(sym, *args, &blk) else super end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
merb-0.0.8 | lib/merb/merb_view_context.rb |