DynMeta
Dynamic Meta Content for Rails
Preface
DynMeta provides a simple interface to utilize i18n for dynamic meta content based on each request. It allows overriding and customization on a per-request basis. The entire gem boils down to a single method which is included into ActionController - :meta. It provides both a setter and a getter which determine a meta value based on your translations file or predefined value. Enough with defining, let me just show you:
Translation Setup
Before using DynMeta you must set up your translations. Your translations must follow the following format:
This format allows for default values to be provided at any depth of a potential request. Let's take a look at a concrete example:
Usage of the id via the translation isn't needed often, but it's a nice-to-have:
Now that your translations are set up you are able to utilize the meta() method to access your content:
To set the content for the page just use meta() as a setter:
Demonstration
You're looking at it! This site is using DynMeta to handle many of the elements within the <head>.