module Roda::RodaPlugins::Render::ClassMethods
Public Instance Methods
Source
# File lib/roda/plugins/render.rb, line 556 def create_template(opts, template_opts) opts[:template_class].new(opts[:path], 1, template_opts, &opts[:template_block]) end
Return an Tilt::Template object based on the given opts and template_opts.
Source
# File lib/roda/plugins/render.rb, line 535 def freeze begin _freeze_layout_method rescue # This is only for optimization, if any errors occur, they can be ignored. # One possibility for error is the app doesn't use a layout, but doesn't # specifically set the :layout=>false plugin option. nil end # Optimize _call_optimized_template_method if you know all templates # are going to be using fixed locals. if render_opts[:assume_fixed_locals] && !render_opts[:check_template_mtime] include AssumeFixedLocalsInstanceMethods end super end
If using compiled methods and there is an optimized layout, speed up access to the layout method to improve the performance of view.
Calls superclass method
Source
# File lib/roda/plugins/render.rb, line 569 def inherited(subclass) super opts = subclass.opts[:render] = subclass.opts[:render].dup if COMPILED_METHOD_SUPPORT opts[:template_method_cache] = (opts[:cache_class] || RodaCache).new end opts[:cache] = opts[:cache].dup opts.freeze end
Copy the rendering options into the subclass, duping them as necessary to prevent changes in the subclass affecting the parent class.
Calls superclass method
Source
# File lib/roda/plugins/render.rb, line 562 def inline_template_block(content) Proc.new{content} end
A proc that returns content, used for inline templates, so that the template doesn’t hold a reference to the instance of the class
Source
# File lib/roda/plugins/render.rb, line 580 def render_opts opts[:render] end
Return the render options for this class.
Private Instance Methods
Source
# File lib/roda/plugins/render.rb, line 587 def _freeze_layout_method if render_opts[:layout] instance = allocate # This needs to be called even if COMPILED_METHOD_SUPPORT is not set, # in order for the precompile_templates plugin to work correctly. instance.send(:retrieve_template, instance.send(:view_layout_opts, OPTS)) if COMPILED_METHOD_SUPPORT && (layout_template = render_opts[:optimize_layout]) && !opts[:render][:optimized_layout_method_created] instance.send(:retrieve_template, :template=>layout_template, :cache_key=>nil, :template_method_cache_key => :_roda_layout) layout_method = opts[:render][:template_method_cache][:_roda_layout] define_method(:_layout_method){layout_method} private :_layout_method alias_method(:_layout_method, :_layout_method) opts[:render] = opts[:render].merge(:optimized_layout_method_created=>true) end end end
Precompile the layout method, to reduce method calls to look it up at runtime.