Module: Roda::RodaPlugins::Partials

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

Overview

The partials plugin adds a partial method, which renders templates without the layout.

plugin :partials, views: 'path/2/views'

Template files are prefixed with an underscore:

partial('test')     # uses _test.erb
partial('dir/test') # uses dir/_test.erb

This is basically equivalent to:

render('_test')
render('dir/_test')

To render the same template once for each object in an enumerable, you can use the render_partials method:

each_partial([1,2,3], :foo) # uses _foo.erb

This is basically equivalent to:

render_each([1,2,3], "_foo", local: :foo)

This plugin depends on the render and render_each plugins.

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.load_dependencies(app, opts = OPTS) ⇒ Object

Depend on the render plugin, passing received options to it. Also depend on the render_each plugin.



34
35
36
37
# File 'lib/roda/plugins/partials.rb', line 34

def self.load_dependencies(app, opts=OPTS)
  app.plugin :render, opts
  app.plugin :render_each
end