Patrick Crowley
  the.railsi.st
Headliner
<%= title :site => quot;My websitequot; %>
class PagesController < ApplicationController
  def about
    @title = quot;About usquot;
  end
end
class PagesController < ApplicationController
  def about
    @title = quot;About usquot;
  end
end

<head>
<title>
Foo.co...
class PagesController < ApplicationController
  def about
    @title = quot;About usquot;
  end
end

<head>
<title>
Foo.co...
class PagesController < ApplicationController
  def about
    @title = quot;About usquot;
  end

  def contact
    @title ...
class PagesController < ApplicationController
  def about
    @title = quot;About usquot;
  end

  def contact
    @title ...
Let’s DRY it up!
<head>
<title>
Foo.com<% if @title %>: <%= @title %><% end %>
</title>
</head>




                   layout
<head>
<%= title :site => quot;Foo.comquot; %>
</head>




                   layout
<h1>About us</h1>

<p>This company sucks.</p>




                    view
<h1><%= title quot;About usquot; %></h1>

<p>This company sucks.</p>




                    view
<html>

<head>
<title>
Foo.com: About us
</title>
</head>

<body>
<h1>About us</h1>
</body>

</html>



            render...
Customize the title
<%= title :separator => quot;&mdash;quot; %>
    quot;Foo.com &mdash; About usquot;

<%= title :prefix => false, :separato...
Use the “t” alias
<html>

<head>
<%= title :site => quot;Foo.comquot; %>
</head>

<body>
<h1><%= title quot;About usquot;></h1>
</body>

</h...
<html>

<head>
<%= t :site => quot;Foo.comquot; %>
</head>

<body>
<h1><%= t quot;About usquot;></h1>
</body>

</html>
Use my method, fool!
Download now at
http://the.railsi.st
The End
Headliner
Upcoming SlideShare
Loading in …5
×

Headliner

1,216 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Headliner

  1. 1. Patrick Crowley the.railsi.st
  2. 2. Headliner <%= title :site => quot;My websitequot; %>
  3. 3. class PagesController < ApplicationController def about @title = quot;About usquot; end end
  4. 4. class PagesController < ApplicationController def about @title = quot;About usquot; end end <head> <title> Foo.com<% if @title %>: <%= @title %><% end %> </title> </head>
  5. 5. class PagesController < ApplicationController def about @title = quot;About usquot; end end <head> <title> Foo.com<% if @title %>: <%= @title %><% end %> </title> </head> <head> <title> Foo.com: About us </title> </head>
  6. 6. class PagesController < ApplicationController def about @title = quot;About usquot; end def contact @title = quot;Contact usquot; end def faq @title = quot;Frequently asked questionsquot; end def press @title = quot;Press centerquot; end end
  7. 7. class PagesController < ApplicationController def about @title = quot;About usquot; end def contact @title = quot;Contact usquot; BAD end def faq @title = quot;Frequently asked questionsquot; end def press @title = quot;Press centerquot; end end
  8. 8. Let’s DRY it up!
  9. 9. <head> <title> Foo.com<% if @title %>: <%= @title %><% end %> </title> </head> layout
  10. 10. <head> <%= title :site => quot;Foo.comquot; %> </head> layout
  11. 11. <h1>About us</h1> <p>This company sucks.</p> view
  12. 12. <h1><%= title quot;About usquot; %></h1> <p>This company sucks.</p> view
  13. 13. <html> <head> <title> Foo.com: About us </title> </head> <body> <h1>About us</h1> </body> </html> rendered page
  14. 14. Customize the title
  15. 15. <%= title :separator => quot;&mdash;quot; %> quot;Foo.com &mdash; About usquot; <%= title :prefix => false, :separator => quot;:quot; %> quot;Foo.com: About usquot; <%= title :lowercase => true %> quot;foo.com : about usquot; <%= title :reverse => true, :prefix => quot;.:.quot; %> quot;About us .:. Foo.comquot;
  16. 16. Use the “t” alias
  17. 17. <html> <head> <%= title :site => quot;Foo.comquot; %> </head> <body> <h1><%= title quot;About usquot;></h1> </body> </html>
  18. 18. <html> <head> <%= t :site => quot;Foo.comquot; %> </head> <body> <h1><%= t quot;About usquot;></h1> </body> </html>
  19. 19. Use my method, fool!
  20. 20. Download now at http://the.railsi.st
  21. 21. The End

×