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

https://github.com/sixarm/sixarm_ruby_html

SixArm.com » Unix » HTML helpers for layouts, lists, tables, etc.
https://github.com/sixarm/sixarm_ruby_html

extensions gem html ruby

Last synced: 4 months ago
JSON representation

SixArm.com » Unix » HTML helpers for layouts, lists, tables, etc.

Awesome Lists containing this project

README

          

# SixArm.com → Ruby →
HTML utility methods to generate lists, tables, etc.

* Doc:
* Gem:
* Repo:

## Introduction

HTML utility methods to generate well-formed HTML for tables, lists, etc.

This is typically to render Ruby objects, such as arrays, as HTML output.

For docs go to

Want to help? We're happy to get pull requests.

## Install

### Gem

To install this gem in your shell or terminal:

gem install sixarm_ruby_html

### Gemfile

To add this gem to your Gemfile:

gem 'sixarm_ruby_html'

### Require

To require the gem in your code:

require 'sixarm_ruby_html'

## Table Methods

* table - Builds an HTML table from the supplied parameters: string CSS: ID, Class; array of strings: Headers, Footers; array of array of string: Rows
* tables - Builds one or more HTML tables from a supplied array of arrays (each sub-array holding the params specified for the table method)
* thead - Builds the thead section of a table from an array of strings
* th - Returns a TH table cell
* ths - Returns a string of TH table cells
* tbody - Builds the tbody section of a table from an array of arrays of strings (each sub-array becomes a table row)
* tr - Returns a TR table row
* trs - Returns a string of TR table rows
* td - Returns a TD table cell
* tds - Returns a string of TD table cells
* tfoot - Builds the tfoot section of a table from an array of strings

## Table Examples

headers = ['a','b','c']
footers = ['x','y','z']
rows=[['d','e,'f']]
table(:id=>'foo', :class=>'bar', :headers=>headers, :footers=>footers, :rows=>rows)
=>



a
b
c




d
e
f




x
y
z


## List Methods

* ul - Builds an HTML unordered list from an array of strings or Enumerables
* uls - Builds one or more HTML unordered lists from an array of arrays of strings or Enumerables (sub-arrays can be a mix of both)
* li - Returns an LI item
* lis - Returns a string of LI items

## List Examples

ul(['a','b','c']) =>


  • a

  • b

  • c

uls(['a','b','c'],['d','e','f'],[1,2,3]) =>


  • a

  • b

  • c


  • d

  • e

  • f


  • 1

  • 2

  • 3

## Misc Methods

* comment - Return the text parameter wrapped in an HTML comment
* wrap - Return the text parameter wrapped in a tag pair

## Misc Examples

comment('the following comes from') =>

wrap('foo', 'bar') =>
foo