Skip to content

Instantly share code, notes, and snippets.

@cupnoodle
Created November 5, 2020 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cupnoodle/db3cdc01ced3be9f5bcec88a2fe6754f to your computer and use it in GitHub Desktop.
Save cupnoodle/db3cdc01ced3be9f5bcec88a2fe6754f to your computer and use it in GitHub Desktop.
Example views/layout/application.html.erb that have multiple yield
<!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>
<% 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