module Roger::Template::Helpers::Partial

The partial helper

Public Instance Methods

partial(name, locals = {}, &block) click to toggle source
# File lib/roger/template/helpers/partial.rb, line 6
def partial(name, locals = {}, &block)
  options = if locals[:locals]
              locals
            else
              { locals: locals }
            end
  if block_given?
    partial_with_block(name, options, &block)
  else
    renderer.render(name, options)
  end
end

Protected Instance Methods

partial_with_block(name, options, &block) click to toggle source

rubocop:disable Lint/Eval

# File lib/roger/template/helpers/partial.rb, line 22
def partial_with_block(name, options, &block)
  block_content = capture(&block)
  result = renderer.render(name, options) { block_content }
  eval "_erbout.concat(#{result.dump})", block.binding
end