module Roda::RodaPlugins::ViewOptions::InstanceMethods
def _cached_template_method_key(template)
Return nil if using custom view or layout options.
def _cached_template_method_key(template) return if @_view_options || @_layout_options if subdir = @_view_subdir template = [subdir, template] end super end
def _cached_template_method_lookup(method_cache, template)
Return nil if using custom view or layout options.
def _cached_template_method_lookup(method_cache, template) return if @_view_options || @_layout_options if subdir = @_view_subdir template = [subdir, template] end super end
def append_view_subdir(v)
the view subdirectory to a subdirectory of the existing
If there has already been a view subdirectory set, this sets
been a view subdirectory set, this just sets it to the argument.
Append a view subdirectory to use. If there hasn't already
def append_view_subdir(v) if subdir = @_view_subdir set_view_subdir("#{subdir}/#{v}") else set_view_subdir(v) end end
def parse_template_opts(template, opts)
template isn't a layout template, merge the options
If view options or locals have been set and this
def parse_template_opts(template, opts) t_opts = super if !t_opts[:_is_layout] && (v_opts = @_view_options) t_opts.merge!(v_opts) end t_opts end
def render_layout_opts
If layout options or locals have been set,
def render_layout_opts opts = super if l_opts = @_layout_options opts.merge!(l_opts) end opts end
def set_layout_options(opts)
def set_layout_options(opts) if options = @_layout_options @_layout_options = options.merge!(opts) else @_layout_options = opts end end
def set_view_options(opts)
def set_view_options(opts) if options = @_view_options @_view_options = options.merge!(opts) else @_view_options = opts end end
def set_view_subdir(v)
Set the view subdirectory to use. This can be set to nil
def set_view_subdir(v) @_view_subdir = v end
def template_name(opts)
there is a view subdirectory and the template name does not
Override the template name to use the view subdirectory if the
def template_name(opts) name = super if (v = @_view_subdir) && name !~ /\// "#{v}/#{name}" else name end end