module Roda::RodaPlugins::ViewOptions::InstanceMethods
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 unless t_opts[:_is_layout] if v_opts = @_view_options t_opts.merge!(v_opts) end if v_locals = @_view_locals t_opts[:locals] = if t_locals = t_opts[:locals] v_locals.merge(t_locals) else v_locals end end 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 if l_locals = @_layout_locals opts[:locals] = if o_locals = opts[:locals] o_locals.merge(l_locals) else l_locals end end opts 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