1-method API for building XHTML tags.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.rubocop.yml
Gemfile
Gemfile.lock
MIT-LICENCE
README.md
Rakefile
tag_helper.gemspec

README.md

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>'

Code Status

Circle CI

License

TagHelper is released under the MIT License.