Class: Calendrier::CalendrierBuilder::SimpleBuilder
- Defined in:
- lib/calendrier/calendrier_builder.rb
Instance Method Summary collapse
Methods inherited from Builder
Constructor Details
This class inherits a constructor from Calendrier::CalendrierBuilder::Builder
Instance Method Details
#render(header, content) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/calendrier/calendrier_builder.rb', line 23 def render(header, content) display = @options[:display] title = @options[:title] || '' cell_date_format = @options[:cell_date_format] || (display == :month ? '%A' : :default) time_slot_title = @options[:time_slot_title] || '' @context.content_tag(:div, nil, :class => "calendar #{display.to_s}") do cal = @context.content_tag(:span, title) cal << @context.content_tag(:table, nil) do unless header.nil? thead = @context.content_tag(:thead, nil) do @context.content_tag(:tr, nil) do ths = "".html_safe ths << @context.content_tag(:th, time_slot_title) if display == :week header.each do |cell_date| ths << @context.content_tag(:th, I18n.l(cell_date, :format => cell_date_format)) end ths end end end unless content.nil? tbody = @context.content_tag(:tbody, nil) do trs = "".html_safe content.each_with_index do |row, index| trs << @context.content_tag(:tr, nil) do tds = "".html_safe tds << @context.content_tag(:td, "#{index}h") if display == :week row.collect do |cell| cell_content = "".html_safe cell_time = cell[:time] cell_content << @context.content_tag(:span, cell_time.day) if display == :month && !cell_time.nil? cell_content << cell[:content] tds << @context.content_tag(:td, cell_content) end tds end end @context.concat trs end end thead.concat(tbody) unless thead.nil? end cal end end |