Class: Hanami::View::Renderer Private
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.
Constant Summary collapse
- PARTIAL_PREFIX =
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.
"_"
- PATH_DELIMITER =
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.
"/"
- CURRENT_PATH_PREFIX =
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.
"."
Instance Attribute Summary collapse
- #config ⇒ Object readonly private
- #prefixes ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(config) ⇒ Renderer
constructor
private
A new instance of Renderer.
- #partial(name, format, scope, &block) ⇒ Object private
- #template(name, format, scope, &block) ⇒ Object private
Constructor Details
#initialize(config) ⇒ Renderer
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.
Returns a new instance of Renderer.
28 29 30 31 |
# File 'lib/hanami/view/renderer.rb', line 28 def initialize(config) @config = config @prefixes = [CURRENT_PATH_PREFIX] end |
Instance Attribute Details
#config ⇒ Object (readonly)
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.
24 25 26 |
# File 'lib/hanami/view/renderer.rb', line 24 def config @config end |
#prefixes ⇒ Object (readonly)
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.
24 25 26 |
# File 'lib/hanami/view/renderer.rb', line 24 def prefixes @prefixes end |
Instance Method Details
#partial(name, format, scope, &block) ⇒ Object
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.
52 53 54 |
# File 'lib/hanami/view/renderer.rb', line 52 def partial(name, format, scope, &block) template(name_for_partial(name), format, scope, &block) end |
#template(name, format, scope, &block) ⇒ Object
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.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/hanami/view/renderer.rb', line 35 def template(name, format, scope, &block) old_prefixes = @prefixes.dup template_path = lookup(name, format) raise TemplateNotFoundError.new(name, format, config.paths) unless template_path new_prefix = File.dirname(name) @prefixes << new_prefix unless @prefixes.include?(new_prefix) render(template_path, scope, &block) ensure @prefixes = old_prefixes end |