Method: ListComponent#initialize
- Defined in:
- lib/html-native/collections.rb
#initialize(data, attributes: {}, ordered: false, &block) ⇒ ListComponent
Creates a new instance of ListComponent from the values of data.
This list can be either ordered or unordered, depending on ordered parameter. If ordered is true, the list will be ordered, otherwise it will be unordered. ordered is false by default.
If a block is given, each item in data is passed to it to render the list items. If no block is given, data are used directly.
174 175 176 177 |
# File 'lib/html-native/collections.rb', line 174 def initialize(data, attributes: {}, ordered: false, &block) @list = ordered ? OrderedListComponent.new(data, attributes, &block) : UnorderedListComponent.new(data, attributes, &block) end |