lib/roda/plugins/render.rb in roda-2.10.0 vs lib/roda/plugins/render.rb in roda-2.11.0
- old
+ new
@@ -75,10 +75,12 @@
# for template code in a file.
# :locals :: Hash of local variables to make available inside the template.
# :path :: Use the value given as the full pathname for the file, instead
# of using the :views and :engine option in combination with the
# template name.
+ # :scope :: The object in which context to evaluate the template. By
+ # default, this is the Roda instance.
# :template :: Provides the name of the template to use. This allows you
# pass a single options hash to the render/view method, while
# still allowing you to specify the template name.
# :template_block :: Pass this block when creating the underlying template,
# ignored when using :inline. Disables caching of the
@@ -213,10 +215,10 @@
module InstanceMethods
# Render the given template. See Render for details.
def render(template, opts = OPTS, &block)
opts = parse_template_opts(template, opts)
merge_render_locals(opts)
- retrieve_template(opts).render(self, (opts[:locals]||OPTS), &block)
+ retrieve_template(opts).render((opts[:scope]||self), (opts[:locals]||OPTS), &block)
end
# Return the render options for the instance's class. While this
# is not currently frozen, it may be frozen in a future version,
# so you should not attempt to modify it.