Skip to content

Commit 35b1a80

Browse files
author
wenjieyeo
committed
Add a full_title helper
1 parent 60d72b5 commit 35b1a80

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

Diff for: app/helpers/application_helper.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
module ApplicationHelper
1+
module ApplicationHelper# Returns the full title on a per-page basis.
2+
3+
def full_title(page_title = '')
4+
base_title = "Ruby on Rails Tutorial Sample App"
5+
if page_title.empty?
6+
base_title
7+
else
8+
page_title + " | " + base_title
9+
end
10+
end
211
end

Diff for: app/views/layouts/application.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title><%= yield(:title) %> | Ruby on Rails Tutorial Sample App</title>
4+
<title><%= full_title(yield(:title)) %></title>
55
<%= csrf_meta_tags %>
66
<%= stylesheet_link_tag 'application', media: 'all',
77
'data-turbolinks-track': 'reload' %>

Diff for: app/views/static_pages/home.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<% provide(:title, "Home") %>
1+
<!--% provide(:title, "Home") %-->
22
<h1>Sample App</h1>
33
<p>
44
This is the home page for the

0 commit comments

Comments
 (0)