@@ -1,2 +1,11 @@
module ApplicationHelper
+ # Returns the full title on a per-page basis.
+ def full_title(page_title = '')
+ base_title = "School Platform"
+ if page_title.empty?
+ base_title
+ else
+ page_title + " | " + base_title
+ end
end
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>SchoolPlatform</title>
+ <title><%= full_title(yield(:title)) %></title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
@@ -1,3 +1,4 @@
+<%= provide(:title, "About") %>
<h1>About</h1>
<p>
School Platform, abbreviated as <i>SchPlat</i>, <i>SPlat</i> or simply
@@ -1,2 +1,3 @@
+<%= provide(:title, "Home") %>
<h1>StaticPages#home</h1>
<p>Find me in app/views/static_pages/home.html.erb</p>
@@ -4,11 +4,13 @@ class StaticPagesControllerTest < ActionDispatch::IntegrationTest
test "should get home" do
get home_url
assert_response :success
+ assert_select "title", "Home | School Platform"
test "should get about" do
get about_url
+ assert_select "title", "About | School Platform"