module Roda::RodaPlugins::BranchLocals::InstanceMethods

def layout_locals

Make branch specific layout locals override render_locals plugin defaults.
def layout_locals
  locals = super
  if @_layout_locals
    locals = Hash[locals].merge!(@_layout_locals)
  end
  locals
end

def render_locals

Make branch specific view locals override render_locals plugin defaults.
def render_locals
  locals = super
  if @_view_locals
    locals = Hash[locals].merge!(@_view_locals)
  end
  locals
end

def set_layout_locals(opts)

Update the default layout locals to use in this branch.
def set_layout_locals(opts)
  if locals = @_layout_locals
    @_layout_locals = locals.merge(opts)
  else
    @_layout_locals = opts
  end
end

def set_view_locals(opts)

Update the default view locals to use in this branch.
def set_view_locals(opts)
  if locals = @_view_locals
    @_view_locals = locals.merge(opts)
  else
    @_view_locals = opts
  end
end