Module: ExpressTemplates::Components::Capabilities::Iterating
- Included in:
- Base
- Defined in:
- lib/express_templates/components/capabilities/iterating.rb
Overview
Adds the capability to iterate over a collection repeating a markup fragment for each member.
Example:
class ParagraphsComponent < ExpressTemplates::Components::Base
emits -> { p { item } } # item is the default local variable name
for_each -> { paragraphs } # evaluated in view context
end
Must specify an iterator
either as a proc to be evaluated in the view context or else as a variable name in the form of a symbol which is assumed to be available in the view context.
Provides:
-
Iterating::ClassMethods (for_each)
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
27 28 29 30 31 |
# File 'lib/express_templates/components/capabilities/iterating.rb', line 27 def self.included(base) base.class_eval do extend ClassMethods end end |