Metaa: meta tags with ease
Metaa adds meta tags to your Rails application with ease.
With Metaa, you can easily add meta tags to your current model with simple DSL, then render these tags on your views with a single method.
Generator
The command is simple, just add the model you want to create the meta for:
rails generate Product
This will generate ProductMeta meta class in your app/meta folder.
Meta definition
After generated, the meta class will look like this:
# app/meta/product_meta.rb
class ProductMeta < Metaa::Meta
def
# Define meta tags of your record here. Each definition will require a hash for the meta attributes,
# and each attribute can be a string, symbol or lambda/proc, for example:
# meta name: "title",
# content: object.title # you can access the record through 'object' variable
end
end
You can define meta tags multiple times and these tags will be displayed in the order you define in meta class.
To access to the final rendered html, just use method meta_tags on your instance
product.
Installation
Add Metaa to your Gemfile:
gem 'metaa'
And run bundle install within your app's directory.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
