Module: Roda::RodaPlugins::Render::ClassMethods

Defined in:
lib/roda/plugins/render.rb

Instance Method Summary collapse

Instance Method Details

#create_template(opts, template_opts) ⇒ Object

Return an Tilt::Template object based on the given opts and template_opts.



441
442
443
# File 'lib/roda/plugins/render.rb', line 441

def create_template(opts, template_opts)
  opts[:template_class].new(opts[:path], 1, template_opts, &opts[:template_block])
end

#freezeObject

If using compiled methods and there is an optimized layout, speed up access to the layout method to improve the performance of view.



426
427
428
429
430
431
432
433
434
435
436
437
# File 'lib/roda/plugins/render.rb', line 426

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

  super
end

#inherited(subclass) ⇒ Object

Copy the rendering options into the subclass, duping them as necessary to prevent changes in the subclass affecting the parent class.



454
455
456
457
458
459
460
461
462
# File 'lib/roda/plugins/render.rb', line 454

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

#inline_template_block(content) ⇒ Object

A proc that returns content, used for inline templates, so that the template doesn’t hold a reference to the instance of the class



447
448
449
# File 'lib/roda/plugins/render.rb', line 447

def inline_template_block(content)
  Proc.new{content}
end

#render_optsObject

Return the render options for this class.



465
466
467
# File 'lib/roda/plugins/render.rb', line 465

def render_opts
  opts[:render]
end