HtmlMeta (beta)

Helps with constructing meta tags

Installation

Add this line to your application's Gemfile:

gem 'html_meta'

And then execute:

$ bundle

Or install it yourself as:

$ gem install html_meta

Usage

In an initializer file set any configuration options:

HtmlMeta.configure do |config|  
    config.title_separator = ' | '
end

Set some defaults in an initializer file:

HtmlMeta.define do
    meta :title, '21purple Web Studios'
    meta :keywords, 'expressionengine developer development php custom web application'
    meta :description, 'We are an awesome web development shop'
end

And then later in a controller action or where ever modify the meta tag values:

HtmlMeta.define do
    meta :title, 'Ruby Development', prepend: true
    meta :keywords, 'ruby rails padrino', append: true
    meta :description, 'We are an awesome ruby web development shop'
    open_graph :title, 'Ruby Developer'
end

You can also use the shorthand method og for setting open graph tags:

HtmlMeta.define do
    og :title, 'Ruby Developer'
end

You can also set a single meta tag value:

HtmlMeta.meta :title, 'Rails Development', prepend: true

Or you can get a meta tag value:

HtmlMeta.meta :title

The open graph tags have similar setters:

HtmlMeta.open_graph :title, 'Rails Development', prepend: true

or 

HtmlMeta.og :title, 'Rails Development', prepend: true

And getters:

HtmlMeta.open_graph :title

or 

HtmlMeta.og :title

And then render the html for the meta tags:

HtmlMeta.render

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request