Class: Mariner::UnorderedListRenderer::GroupRenderer

Inherits:
Renderer::Base show all
Defined in:
lib/mariner/unordered_list_renderer.rb

Instance Attribute Summary

Attributes inherited from Renderer::Base

#rendering_strategy, #subject

Instance Method Summary collapse

Methods inherited from Renderer::Base

#initialize

Constructor Details

This class inherits a constructor from Mariner::Renderer::Base

Instance Method Details

#renderObject

Public: Render a Store as an unordererd list HTML element.



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/mariner/unordered_list_renderer.rb', line 166

def render
  open_surround = close_surround = item_open_surround = item_close_surround = ""

  open_surround = "<ul class='#{rendering_strategy.group_classname}'>"
  close_surround = "</ul>"

  item_open_surround = "<li>"
  item_close_surround = "</li>"

  rendered_configurations = subject.configurations.map do |config|
    name, entity = config
    unless subject.virtual?
      "#{item_open_surround}#{entity.render(rendering_strategy)}#{item_close_surround}"
    else
      entity.render(rendering_strategy)
    end
  end.join

  unless subject.virtual?
    result = ""
    result << open_surround

    if rendering_strategy.render_titles?
      result << "<li class='#{rendering_strategy.title_classname}'>#{subject.name.to_s.titleize}#{item_close_surround}"
    end

    result << "#{rendered_configurations}#{close_surround}"
  else
    rendered_configurations
  end
end