Module: Roda::RodaPlugins::RenderEach

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

Overview

The render_each plugin allows you to render a template for each value in an enumerable, returning the concatention of all of the template renderings. For example:

render_each([1,2,3], :foo)

will render the foo template 3 times. Each time the template is rendered, the local variable foo will contain the given value (e.g. on the first rendering foo is 1).

You can pass additional render options via an options hash:

render_each([1,2,3], :foo, :views=>'partials')

One additional option supported by is :local, which sets the local variable containing the current value to use. So:

render_each([1,2,3], :foo, :local=>:bar)

Will render the foo template, but the local variable used inside the template will be bar. You can use :local=>nil to not set a local variable inside the template.

Defined Under Namespace

Modules: InstanceMethods

Constant Summary collapse

OPTS =
{}.freeze

Class Method Summary collapse

Class Method Details

.load_dependencies(app) ⇒ Object

Load the render plugin before this plugin, since this plugin calls the render method.



33
34
35
# File 'lib/roda/plugins/render_each.rb', line 33

def self.load_dependencies(app)
  app.plugin :render
end