Class: Hanami::View::Rendering::TemplatesFinder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/view/rendering/templates_finder.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.

Find templates for a view

See Also:

Since:

  • 0.1.0

Direct Known Subclasses

TemplateFinder

Constant Summary collapse

FORMAT =

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

Default format

Since:

  • 0.1.0

'*'.freeze
ENGINES =

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

Default template engines

Since:

  • 0.1.0

'*'.freeze
RECURSIVE =

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

Recursive pattern

Since:

  • 0.2.0

'**'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ TemplatesFinder

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 finder

Parameters:

  • view (Class)

    the view

Since:

  • 0.1.0



37
38
39
# File 'lib/hanami/view/rendering/templates_finder.rb', line 37

def initialize(view)
  @view = view
end

Instance Method Details

#findArray<Hanami::View::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.

Find all the associated templates to the view. It recursively looks for templates under the root path of the view, that are matching the template name

Examples:

require 'hanami/view'

module Articles
  class Show
    include Hanami::View
  end
end

Articles::Show.root     # => "/path/to/templates"
Articles::Show.template # => "articles/show"

# This view has a template:
#
#   "/path/to/templates/articles/show.html.erb"

Hanami::View::Rendering::TemplatesFinder.new(Articles::Show).find
  # => [#<Hanami::View::Template:0x007f8a0a86a970 ... @file="/path/to/templates/articles/show.html.erb">]

Returns:

See Also:

Since:

  • 0.1.0



71
72
73
74
75
# File 'lib/hanami/view/rendering/templates_finder.rb', line 71

def find
  _find.map do |template|
    View::Template.new(template, @view.configuration.default_encoding)
  end
end