Class: Dry::View::Renderer Private
- Inherits:
-
Object
- Object
- Dry::View::Renderer
- Extended by:
- Core::Cache
- Defined in:
- lib/dry/view/renderer.rb
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.
"/"
Instance Attribute Summary collapse
- #engine_mapping ⇒ Object readonly private
- #format ⇒ Object readonly private
- #options ⇒ Object readonly private
- #paths ⇒ Object readonly private
Instance Method Summary collapse
- #chdir(dirname) ⇒ Object private
-
#initialize(paths, format:, engine_mapping: nil, **options) ⇒ Renderer
constructor
private
A new instance of Renderer.
- #partial(name, scope, &block) ⇒ Object private
- #render(path, scope, &block) ⇒ Object private
- #template(name, scope, **lookup_options, &block) ⇒ Object private
Constructor Details
#initialize(paths, format:, engine_mapping: nil, **options) ⇒ 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.
21 22 23 24 25 26 |
# File 'lib/dry/view/renderer.rb', line 21 def initialize(paths, format:, engine_mapping: nil, **) @paths = paths @format = format @engine_mapping = engine_mapping || {} @options = end |
Instance Attribute Details
#engine_mapping ⇒ 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.
19 20 21 |
# File 'lib/dry/view/renderer.rb', line 19 def engine_mapping @engine_mapping end |
#format ⇒ 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.
19 20 21 |
# File 'lib/dry/view/renderer.rb', line 19 def format @format end |
#options ⇒ 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.
19 20 21 |
# File 'lib/dry/view/renderer.rb', line 19 def @options end |
#paths ⇒ 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.
19 20 21 |
# File 'lib/dry/view/renderer.rb', line 19 def paths @paths end |
Instance Method Details
#chdir(dirname) ⇒ 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 55 56 |
# File 'lib/dry/view/renderer.rb', line 52 def chdir(dirname) new_paths = paths.map { |path| path.chdir(dirname) } self.class.new(new_paths, format: format, **) end |
#partial(name, 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.
38 39 40 41 42 43 44 45 46 |
# File 'lib/dry/view/renderer.rb', line 38 def partial(name, scope, &block) template( name_for_partial(name), scope, child_dirs: %w[shared], parent_dir: true, &block ) end |
#render(path, 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.
48 49 50 |
# File 'lib/dry/view/renderer.rb', line 48 def render(path, scope, &block) tilt(path).render(scope, &block) end |
#template(name, scope, **lookup_options, &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.
28 29 30 31 32 33 34 35 36 |
# File 'lib/dry/view/renderer.rb', line 28 def template(name, scope, **, &block) path = lookup(name, **) if path render(path, scope, &block) else raise TemplateNotFoundError.new(name, paths) end end |