Skip to content
/ easytitles Public

Ruby on Rails plugin to easily manage the titles of your pages using YAML files

License

Notifications You must be signed in to change notification settings

ahe/easytitles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EasyTitles

EasyTitles is a Ruby on Rails plugin that allows you to easily manage the titles of your pages. Instead of creating @title variables inside your controllers & views, EasyTitles gives you the possiblity to centralize your titles in YAML files. This plugin also supports internationalization (I18n) if you use a version of Rails >= 2.2.

The big advantage is that all titles are centralized in one place, making them easy to manage.

Let’s say that you have a REST “Articles” controller (with basic CRUD methods), the only one thing you have to do is to create a YAML file respecting the following format :

articles:
  index: "Listing articles"
  show: "Article details"
  new: "New article"
  edit: "Edit article"

You can then add a call to the easy_title helper method in the title tag of your layout :

<title><%= easy_title %></title>

This method will determine the title to display in function of the current controller name & action name. So if you are on the /articles/show page, the title “Article details” will be displayed.

EasyTitles also allows you to set default titles :

default: "This title will be displayed for any controller/action without a defined title"
articles:
  default: "This title will be displayed for articles methods without a defined title"
  index: "Listing articles"
  show: "Article details"
  new: "New article"
  edit: "Edit article"

If you need a dynamic title for some actions, you can create a @page_title instance variable in your controller. The easy_title helper method will automatically return @page_title if it is defined.

Installation

-script/plugin install git://github.com/ahe/easytitles.git

-The installation created a titles folder in your config folder (RAILS_ROOT/config/titles).

-If you are not using I18n (internationalization) use config/titles/all.yml to store your titles.

-Otherwise, create a yml file for each locale (en.yml, fr.yml, …) in your titles folder.

-Add the easy_title call in your title tag : <title><%= easy_title %></title>

Author

Anthony Heukmes

www.2dconcept.com www.twitter.com/2dc

About

Ruby on Rails plugin to easily manage the titles of your pages using YAML files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages