Project

tag_helper

0.02
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Zero dependency, lightweight API for building XHTML tags
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 10.4.2, ~> 10.4
~> 0.35.1
>= 3.1.5, ~> 3.1
 Project Readme

TagHelper

1-method API for building XHTML tags.

Installation

Add this line to your application's Gemfile:

gem 'tag_helper'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tag_helper

Usage

There's only one method to be used: tag.

  • Use the first argument to indicate the tag name.
  • Other arguments will map to tag attributes.
  • Use block for tag content. If the block is not provided, the tag will be self-closing.
require 'tag_helper'

include TagHelper

tag(:img, src: '1.png', alt: 'number one!')
# => '<img src="1.png" alt="number one!" />'

tag(:br)
# => '<br />'

tag(:label, for: 'name') { 'Name' }
# => '<label for="name">Name</label>'

tag(:div) do
  tag(:form) do
    tag(:input, type: 'text')
  end
end
# => '<div><form><input type="text" /></form></div>'

License

TagHelper is released under the MIT License.