Project

carender

0.01
No commit activity in last 3 years
No release in over 3 years
A monthly calendar for Rails application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

Carender

Gem Version Build Status

This gem renders a monthly calendar for Ruby on Rails application.

Usage

This gem automatically renders a monthly calendar as HTML table by fetching params[:year] and params[:month] at view context. Following code renders a simple monthly calendar:

<%= carender do |date| %>
  <%= date.day %>
<% end %>

The content passed as a block is rendered in each cell. For example, above code renders like following HTML table.

<table>
  <tr><th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th></tr>
  <tr><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr>
  <tr><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td></tr>
  ...
</table>

Collection

To render a calendar with a collection which is grouped by the specified column, you can pass :collection and :column arguments like as follows:

<%= carender collection: @posts, column: :posted_on do |date, posts| %>
  <% posts.each do |post| %>
    <%= link_to post.title, post %>
  <% end %>
<% end %>

Installation

Add this line to your application's Gemfile:

gem 'carender'

And then execute:

$ bundle

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kami-zh/carender. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.