Class: Stencil::ListCapsule

Inherits:
Capsule
  • Object
show all
Defined in:
lib/stencil/view.rb

Instance Attribute Summary

Attributes inherited from Capsule

#block

Instance Method Summary collapse

Constructor Details

#initialize(render_class, &block) ⇒ ListCapsule

Returns a new instance of ListCapsule.



72
73
74
75
# File 'lib/stencil/view.rb', line 72

def initialize(render_class, &block)
  super
  @mapping = nil
end

Instance Method Details

#map(&block) ⇒ Object



77
78
79
80
# File 'lib/stencil/view.rb', line 77

def map(&block)
  @mapping = ViewHost.sub_view(@render_class, &block)
  self
end

#render(data) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/stencil/view.rb', line 82

def render(data)
  list = super
  rendered = list.map do |item|
    @mapping.viewset(item)
  end
  rendered
end