Socket
Book a DemoInstallSign in
Socket

html_skeleton

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html_skeleton

0.5.8
bundlerRubygems
Version published
Maintainers
1
Created
Source

HtmlSkeleton

Gem Version Downloads GitHub Build Ruby Style Guide MIT License

HtmlSkeleton provides the frame for a calendar or a table, i.e. no loops are required to build up the HTML structure. Filling the skeleton is done via parameters and, in particular, with procs (Proc.new, lambda). See below Default Options.

Installation

As usual:

# Gemfile
gem "html_skeleton"

and run "bundle install".

Calendar

A simple helper for creating an HTML calendar. The "calendar" method will be available to your view templates.

Procs may be supplied to generate particular HTML-code for a day or the year. In the example below clicking a day triggers an action.

Examples

HtmlSkeleton.new.calendar                  # calendar for current year
HtmlSkeleton.new.calendar year: 2012       # calendar for year 2012
HtmlSkeleton.new.calendar year: 2012, month: 8  # calendar for August 2012

HtmlSkeleton.new.calendar {|date|
  link = "/#{controller_name}/toggle/#{@resource.id}?date=#{date}"
  style = @resource.holidays.include?(date.to_s) ?
           'font-weight:bold; color:red' : ''
  %Q{ <a style="#{style}" href="#{link}"> #{date.day.to_s} </a>}
}

Default Options

year:        DateTime.now.year,
title:       DateTime.now.year,
rows:        3,
calendar_class: 'skeleton',
day_names:   Date::DAYNAMES.dup,
month_names: Date::MONTHNAMES,
abbrev:      (0..1),
cell_proc:   block || ->(d) { d.day.to_s},
first_day_of_week: 1

Inspired by calendar_helper:

Table

A simple helper for creating an HTML table.

Table only takes care of the HTML tags and expects lambdas/strings to be supplied by the user.

Examples

rows = %w{a bb ccc}
cols = %w{1 22}
HtmlSkeleton.new.table(rows, cols) {|row, col|
  col == '1' ? '<td>bingo</td>' : '<td></td>'
}
HtmlSkeleton.new.table(@users, %w{email address},
  th_attribute: lambda { |col| col.name },
  legend: 'Users') { |row, col| "<td>#{ row.send(col) }</td>" }
stripes = %w{odd even}
proc = ->(row) { k = stripes.shift; stripes << k; %Q{class="#{k}"} }
HtmlSkeleton.new.table(@users, %w{email address},
            tr_attribute: proc,
            legend: 'Users') { |row, col|
  "<td>#{ row.send(col) }</td>"
}

Default Options

legend: nil,
col_legend:   ->(x) { x.to_s },
row_legend:   ->(x) { x.id },
th_attribute: ->(col) { nil },
tr_attribute: ->(row) { nil },
table_class:  'skeleton',
cell_proc:    block || ->(row, col) { "<td>#{row} #{col}</td>"}

Curious?

  • github.com/cthulhu666/easy_table
  • github.com/giniedp/fancygrid
  • github.com/hunterae/table-for
  • github.com/jgdavey/tabletastic
  • github.com/lunich/table_for
  • github.com/watu/table_builder
  • ruby-toolbox.com/projects/tableasy

Miscellaneous

Copyright (c) 2012-2025 Dittmar Krall (www.matiq.com), released under the MIT license.

FAQs

Package last updated on 18 Jun 2025

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.