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
:title, '21purple Web Studios'
:keywords, 'expressionengine developer development php custom web application'
: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
:title, 'Ruby Development', prepend: true
:keywords, 'ruby rails padrino', append: true
: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. :title, 'Rails Development', prepend: true
Or you can get a meta tag value:
HtmlMeta. :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
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request