Socket
Book a DemoInstallSign in
Socket

html_calendar

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html_calendar

0.0.1
bundlerRubygems
Version published
Maintainers
2
Created
Source

HtmlCalendar

HtmlCalendar is an extremely lightweight/extensible gem for creating HTML calendars in Rails (>= 3.1).

Want to overwrite the built-in views? No problem. Want clean markup? It'll give you clean markup. Want a full-featured Google Calendar clone? It'll give you clean markup.

Installation

  • Add gem "html_calendar" to your Gemfile
  • bundle

Creating calendars

The html_calendar helper makes it easy to create a calendar for any date:

<!-- a calendar for the current month -->
<%= html_calendar %>

<!-- a calender for 3 months in the future -->
<%= html_calendar Date.current + 3.months %>

If you need customized date logic, you can also pass html_calendar a presenter:

<%= html_calendar Date.current, presenter: MyCustomDatePresenter %>

Your presenter class needs to inherit from HTMLCalendar::DatePresenter, and should implement the html_classes method.

class MyCustomDatePresenter < HTMLCalendar::DatePresenter
  # Available methods: `html_classes`, `date` and `template`

  def html_classes
    if monday?
      ['a-case-of-the-mundays']
    else
      super
    end
  end

  private

  def monday?
    date.wday == 1
  end
end

Overwriting views

You can overwrite any of the view partials by creating a directory at app/views/html_calendar/calendar and adding replacement files:

NameDescription
_calendar.html.erbMain calendar loop
_day.html.erbSingle day cell (in current month)
_header.html.erbTable header (including day names)
_other_month_day.html.erbSingle day cell for days displayed but not in current month

Future Plans

  • I18n support
  • Better test coverage
  • Basic stylesheet (opt-in)
  • Ability to overwrite partial path

FAQs

Package last updated on 01 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.