Module: Roda::RodaPlugins::Render::ClassMethods
- Defined in:
- lib/roda/plugins/render.rb
Instance Method Summary collapse
-
#create_template(opts, template_opts) ⇒ Object
Return an Tilt::Template object based on the given opts and template_opts.
-
#freeze ⇒ Object
If using compiled methods and there is an optimized layout, speed up access to the layout method to improve the performance of view.
-
#inherited(subclass) ⇒ Object
Copy the rendering options into the subclass, duping them as necessary to prevent changes in the subclass affecting the parent class.
-
#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.
-
#render_opts ⇒ Object
Return the render options for this class.
Instance Method Details
#create_template(opts, template_opts) ⇒ Object
Return an Tilt::Template object based on the given opts and template_opts.
568 569 570 |
# File 'lib/roda/plugins/render.rb', line 568 def create_template(opts, template_opts) opts[:template_class].new(opts[:path], 1, template_opts, &opts[:template_block]) end |
#freeze ⇒ Object
If using compiled methods and there is an optimized layout, speed up access to the layout method to improve the performance of view.
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
# File 'lib/roda/plugins/render.rb', line 547 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 |
#inherited(subclass) ⇒ Object
Copy the rendering options into the subclass, duping them as necessary to prevent changes in the subclass affecting the parent class.
581 582 583 584 585 586 587 588 589 |
# File 'lib/roda/plugins/render.rb', line 581 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
574 575 576 |
# File 'lib/roda/plugins/render.rb', line 574 def inline_template_block(content) Proc.new{content} end |
#render_opts ⇒ Object
Return the render options for this class.
592 593 594 |
# File 'lib/roda/plugins/render.rb', line 592 def render_opts opts[:render] end |