module Roda::RodaPlugins::ViewOptions::InstanceMethods
Public Instance Methods
Source
# File lib/roda/plugins/view_options.rb, line 95 def append_view_subdir(v) if subdir = @_view_subdir set_view_subdir("#{subdir}/#{v}") else set_view_subdir(v) end end
Append a view subdirectory to use. If there hasn’t already been a view subdirectory set, this just sets it to the argument. If there has already been a view subdirectory set, this sets the view subdirectory to a subdirectory of the existing view subdirectory.
Source
# File lib/roda/plugins/view_options.rb, line 110 def set_layout_options(opts) if options = @_layout_options @_layout_options = options.merge!(opts) else @_layout_options = opts end end
Set branch/route options to use when rendering the layout
Source
# File lib/roda/plugins/view_options.rb, line 119 def set_view_options(opts) if options = @_view_options @_view_options = options.merge!(opts) else @_view_options = opts end end
Set branch/route options to use when rendering the view
Source
# File lib/roda/plugins/view_options.rb, line 105 def set_view_subdir(v) @_view_subdir = v end
Set the view subdirectory to use. This can be set to nil to not use a view subdirectory.
Private Instance Methods
Source
# File lib/roda/plugins/view_options.rb, line 132 def _cached_template_method_key(template) return if @_view_options || @_layout_options if subdir = @_view_subdir template = [subdir, template].freeze end super end
Return nil if using custom view or layout options. If using a view subdir, prefix the template key with the subdir.
Source
# File lib/roda/plugins/view_options.rb, line 144 def _cached_template_method_lookup(method_cache, template) return if @_view_options || @_layout_options if subdir = @_view_subdir template = [subdir, template] end super end
Return nil if using custom view or layout options. If using a view subdir, prefix the template key with the subdir.
Source
# File lib/roda/plugins/view_options.rb, line 158 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
If view options or locals have been set and this template isn’t a layout template, merge the options and locals into the returned hash.
Source
# File lib/roda/plugins/view_options.rb, line 170 def render_layout_opts opts = super if l_opts = @_layout_options opts.merge!(l_opts) end opts end
If layout options or locals have been set, merge the options and locals into the returned hash.
Source
# File lib/roda/plugins/view_options.rb, line 183 def template_name(opts) name = super if (v = @_view_subdir) && use_view_subdir_for_template_name?(name) "#{v}/#{name}" else name end end
Override the template name to use the view subdirectory if the there is a view subdirectory and the template name does not contain a slash.
Source
# File lib/roda/plugins/view_options.rb, line 193 def use_view_subdir_for_template_name?(name) !name.include?('/') end
Whether to use a view subdir for the template name.