Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zenizh/carender

📅 A monthly calendar for Rails application
https://github.com/zenizh/carender

calendar gem rails ruby

Last synced: 3 months ago
JSON representation

📅 A monthly calendar for Rails application

Awesome Lists containing this project

README

        

# Carender

[![Gem Version](https://badge.fury.io/rb/carender.svg)](https://badge.fury.io/rb/carender)
[![Build Status](https://travis-ci.org/kami-zh/carender.svg?branch=master)](https://travis-ci.org/kami-zh/carender)

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:

```erb
<%= 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.

```html

SunMonTueWedThuFriSat
123456
78910111213
...

```

### 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:

```erb
<%= 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:

```ruby
gem 'carender'
```

And then execute:

```bash
$ 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](http://contributor-covenant.org) code of conduct.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).