       functions: core.define_functions {}, function_names
       vars: vars
 
+      in_context: (context, fn) ->
+        previous_context = @root_context.current_context
+        @root_context.current_context = context
+        context_overridden = @root_context.context_overridden
+        @root_context.context_overridden = true
+        try
+          fn()
+        finally
+          @root_context.current_context = previous_context
+          @root_context.context_overridden = context_overridden
+
       render: (o) ->
         @nested 'renderable', handle_renderable, o
         # TODO warn if not renderable


        nested_context = _.extend {}, run_context,
          output: output $item

        nested_context.cli = bind_cli nested_context, cli
        fn.apply nested_context, args


          scroll_to_top()

    run_context.cli = cli = bind_cli run_context, ops
    run_context.current_context = run_context
    run_context.root_context = run_context
    _.defaults run_context, extra_contexts...

    run_context
