Class: Hanami::View::Rendering::Template Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/view/rendering/template.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Rendering template

It’s used when a template wants to render another template.

Examples:

# We have an application template (templates/application.html.erb)
# that uses the following line:

<%= render template: 'articles/show' %>

See Also:

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(view, options) ⇒ Template

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a template

Parameters:

  • view (Hanami::View)

    the current view

  • options (Hash)

    the rendering informations

Options Hash (options):

  • :format (Symbol)

    the current format

  • :locals (Hash)

    the set of objects available within the rendering context

Since:

  • 0.1.0



31
32
33
# File 'lib/hanami/view/rendering/template.rb', line 31

def initialize(view, options)
  @view, @options = view, options
end

Instance Method Details

#renderString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Render the template.

Returns:

  • (String)

    the output of the rendering process.

Raises:

Since:

  • 0.1.0



43
44
45
# File 'lib/hanami/view/rendering/template.rb', line 43

def render
  (template or raise_missing_template_error).render(scope)
end