By JeremyVoorhis and ShachafBenKiki

Screenshot:
http://jvoorhis.com/images/screenshot.png
Minimal configuration for maximum zen:
http://jvoorhis.com/images/screenshot-minimal.png
Src:
http://jvoorhis.com/downloads/calendar_helper.rb
Hasty usage application (in progress):
http://jvoorhis.com/downloads/webcalendar.zip

Inspired by ASP.NET's @System.Web.UI.\WebControls.Calendar@, this calendar helper allows you to draw a databound calendar with fine-grained CSS formatting without introducing any new requirements for your models, routing schemes, etc. 

Not to be confused with MichaelSchuerig's CalendarHelper which is recommended if your forms allow users to select a date, DynamicCalendarHelper accepts a block as an argument. Suggested use is to retrieve your data and then define the block in your controller using @lamda@ or @Proc.new@. It is recommended to select your data outside of the block, creating a lexical closure. Then it is possible to hit the database only one time as opposed to 28-31 times. It also allows for very natural routing schemes such as http://example.com/2005/06

For full documentation, run RDoc in the directory containing calendar_helper.rb

h2. Usage example

h3. Controller:

<pre><code>
class CalendarController < ApplicationController

  def index
    @year = @params[:year].to_i
    @month = @params[:month].to_i

    events = Event.find(:all)

    @databinder = lambda do |d|
      cell_text = "#{d.mday}<br />"
      cell_attrs = {:class => 'day'}
      events.each do |e|
        if e.startdate == d
          cell_text << e.name << "<br />"
          cell_attrs[:class] = 'specialDay'
        end
      end
      [cell_text, cell_attrs]
    end
  end

end
</code></pre>

h3. View:

<pre><code>
<%= calendar({:year => @year, :month => @month}, &@databinder) %>
</code></pre>

