Created
November 5, 2020 08:46
-
-
Save cupnoodle/db3cdc01ced3be9f5bcec88a2fe6754f to your computer and use it in GitHub Desktop.
Example views/layout/application.html.erb that have multiple yield
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Sample Rails app</title> | |
<%= csrf_meta_tags %> | |
<%= csp_meta_tag %> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> | |
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> | |
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> | |
<!-- Here we can insert a custom yield --> | |
<%= yield(:head) %> | |
</head> | |
<body> | |
<%= yield %> | |
</body> | |
</html> |
This file contains hidden or 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
<% content_for :head do %> | |
<!-- header content specific to this page, this is what the '<%= yield(:head) %>' in application.html.erb will output --> | |
<%= javascript_pack_tag 'GallerieSwiper' %> | |
<% end %> | |
<!-- Body content for '<%= yield %> --> | |
<h1> Your normal body content here </h1> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment