Module: DefV::TitleHelper
- Defined in:
- lib/title_helper.rb
Instance Method Summary collapse
-
#title(arguments, options = {}) ⇒ Object
This method should be used in your layout and your actions.
Instance Method Details
#title(arguments, options = {}) ⇒ Object
This method should be used in your layout and your actions.
In your action:
<%= title "Edit user #{@user.name}" %>
> <h1>Edit user Jan De Poorter</h1>
In your layout:
<head>
<title><%= title :site_name => 'Foobar' %></title>
...
> <title>Edit user Jan De Poorter - Foobar</title>
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/title_helper.rb', line 17 def title arguments, = {} case arguments when String @title = arguments [:class] = [[:class], 'error'].compact.join(' ') if [:error] title = [[:header], @title, [:trailer]].compact.join(' ') title = title.html_safe if title.respond_to?(:html_safe) return content_tag(:h1, title, .except(:error, :header, :trailer)) when Hash sitename = arguments[:site_name] if @title return "#{(@title)} - #{sitename}" else return "#{sitename}" end end end |