Class: Hanami::View::Rendering Private

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

Since:

  • 2.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_data:, format:, context:) ⇒ Rendering

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 Rendering.

Since:

  • 2.1.0



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hanami/view/rendering.rb', line 19

def initialize(config_data:, format:, context:)
  @format = format

  @inflector = config_data.inflector
  @part_builder = config_data.part_builder
  @scope_builder = config_data.scope_builder

  @part_class = config_data.part_class
  @part_namespace = config_data.part_namespace
  @scope_class = config_data.scope_class
  @scope_namespace = config_data.scope_namespace
  @cache_key = config_data.object_id

  @context = context.dup_for_rendering(self)
  @renderer = Renderer.new(config_data)
end

Instance Attribute Details

#cache_keyObject (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.

Stable identity for the underlying config snapshot.

Since:

  • 2.1.0



15
16
17
# File 'lib/hanami/view/rendering.rb', line 15

def cache_key
  @cache_key
end

#contextObject (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.

Since:

  • 2.1.0



17
18
19
# File 'lib/hanami/view/rendering.rb', line 17

def context
  @context
end

#formatObject (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.

Since:

  • 2.1.0



8
9
10
# File 'lib/hanami/view/rendering.rb', line 8

def format
  @format
end

#inflectorObject (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.

Since:

  • 2.1.0



10
11
12
# File 'lib/hanami/view/rendering.rb', line 10

def inflector
  @inflector
end

#part_builderObject (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.

Since:

  • 2.1.0



10
11
12
# File 'lib/hanami/view/rendering.rb', line 10

def part_builder
  @part_builder
end

#part_classObject (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.

Since:

  • 2.1.0



12
13
14
# File 'lib/hanami/view/rendering.rb', line 12

def part_class
  @part_class
end

#part_namespaceObject (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.

Since:

  • 2.1.0



12
13
14
# File 'lib/hanami/view/rendering.rb', line 12

def part_namespace
  @part_namespace
end

#rendererObject (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.

Since:

  • 2.1.0



17
18
19
# File 'lib/hanami/view/rendering.rb', line 17

def renderer
  @renderer
end

#scope_builderObject (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.

Since:

  • 2.1.0



10
11
12
# File 'lib/hanami/view/rendering.rb', line 10

def scope_builder
  @scope_builder
end

#scope_classObject (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.

Since:

  • 2.1.0



12
13
14
# File 'lib/hanami/view/rendering.rb', line 12

def scope_class
  @scope_class
end

#scope_namespaceObject (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.

Since:

  • 2.1.0



12
13
14
# File 'lib/hanami/view/rendering.rb', line 12

def scope_namespace
  @scope_namespace
end

Instance Method Details

#current_template_nameString?

Returns the resolved name of the template or partial currently being rendered, or nil if no render is in progress.

Returns:

Since:

  • x.x.x



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

def current_template_name
  renderer.current_template_name
end

#current_template_namesArray<String>

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 the stack of resolved names for the templates and partials currently being rendered.

Returns:

Since:

  • x.x.x



54
55
56
# File 'lib/hanami/view/rendering.rb', line 54

def current_template_names
  renderer.current_template_names
end

#part(name, value, as: nil) ⇒ 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.

Since:

  • 2.1.0



66
67
68
# File 'lib/hanami/view/rendering.rb', line 66

def part(name, value, as: nil)
  part_builder.(name, value, as: as, rendering: self)
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.

Since:

  • 2.1.0



62
63
64
# File 'lib/hanami/view/rendering.rb', line 62

def partial(name, scope, &block)
  renderer.partial(name, format, scope, &block)
end

#scope(name = nil, locals) ⇒ 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.

rubocop:disable Style/OptionalArguments

Since:

  • 2.1.0



70
71
72
# File 'lib/hanami/view/rendering.rb', line 70

def scope(name = nil, locals) # rubocop:disable Style/OptionalArguments
  scope_builder.(name, locals: locals, rendering: self)
end

#template(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.

Since:

  • 2.1.0



58
59
60
# File 'lib/hanami/view/rendering.rb', line 58

def template(name, scope, &block)
  renderer.template(name, format, scope, &block)
end