Module: Roda::RodaPlugins::BranchLocals

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

Overview

The branch_locals plugin allows you to override view and layout locals for specific branches and routes.

plugin :render
plugin :render_locals, render: {footer: 'Default'}, layout: {title: 'Main'}
plugin :branch_locals

route do |r|
r.on "users" do
  set_layout_locals title: 'Users'
  set_view_locals footer: '(c) Roda'
end
end

The locals you specify in the set_layout_locals and set_view_locals methods have higher precedence than the render_locals plugin options, but lower precedence than options you directly pass to the view/render methods.

Defined Under Namespace

Modules: InstanceMethods

Constant Summary collapse

SCOPE_INSTANCE_VARIABLES =
[:@_layout_locals, :@_view_locals].freeze

Class Method Summary collapse

Class Method Details

.load_dependencies(app) ⇒ Object

Load the render_locals plugin before this plugin, since this plugin works by overriding methods in the render_locals plugin.



28
29
30
# File 'lib/roda/plugins/branch_locals.rb', line 28

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