Creating a portfolio I found it quite a hassle to recreate the footer and header from scratch every time the page changed, and as soon as I looked it up, it came out so let me share it!
This app> layouts> application.html.erb In
application.html.erb
#It has already been described when opened
<!DOCTYPE html>
<html>
<head>
<title>PhotoRoke</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
#Describe the header here
<%= yield %>
#Describe the footer here
</body>
</html>
<%= yield %> Let's write it as if it is sandwiched between the footer and the header!
It is a method to expand each template file to the layout template. And that
The layout template is the applocation.html.erb that you edited earlier in Rails. In Rails, that means that different files in other languages may be layout templates.
Very simply yield = HTML on top page yield = HTML for new post page yield = HTML for other pages HTML of each page goes inside in yield like
That's it! Let's do some programming Thank you for visiting!
Recommended Posts