module Roda::RodaPlugins::AdditionalRenderEngines

  1. lib/roda/plugins/additional_render_engines.rb

The additional_render_engines plugin allows for specifying additional render engines to consider for templates. When rendering a template, it will first try the default template engine specified in the render plugin. If the template file to be rendered does not exist, it will try each additional render engine specified in this plugin, in order, using the path to the first template file that exists in the file system. If no such path is found, it uses the default path specified by the render plugin.

Example:

plugin :render # default engine is 'erb'
plugin :additional_render_engines, ['haml', 'str']

route do |r|
  # Will check the following in order, using path for first
  # template file that exists:
  # * views/t.erb
  # * views/t.haml
  # * views/t.str
  render :t
end

Methods

Public Class

  1. configure
  2. load_dependencies

Public Class methods

configure(app, render_engines)

Set the additional render engines to consider.

[show source]
   # File lib/roda/plugins/additional_render_engines.rb
33 def self.configure(app, render_engines)
34   app.opts[:additional_render_engines] = render_engines.dup.freeze
35 end
load_dependencies(app, render_engines)
[show source]
   # File lib/roda/plugins/additional_render_engines.rb
28 def self.load_dependencies(app, render_engines)
29   app.plugin :render
30 end