-
-
Save jnx/d57d609a3090d30fca9216ad656399f5 to your computer and use it in GitHub Desktop.
Simple to set a page title dynamically Ruby on Rails. Set page title with ternary operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Set page title with ternary operator --> | |
<!-- application layout --> | |
<title><%= content_for?(:page_title) ? yield(:page_title) : default_page_title %></title> | |
<!-- view --> | |
<% set_page_title(@page_title) %> | |
<!-- application helper --> | |
def set_page_title(title) | |
content_for :page_title, title | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment