Skip to content

Instantly share code, notes, and snippets.

@avit
Created May 6, 2011 16:45
Show Gist options
  • Save avit/959319 to your computer and use it in GitHub Desktop.
Save avit/959319 to your computer and use it in GitHub Desktop.
Rails Layout & yield blocks
<html>
<head>
<title>My Cool Site : <%= yield :title %></title>
</head>
<body>
<div id="main">
<%= yield %>
</div>
<div id="sidebar">
<%= yield :sidebar %>
</div>
</body>
</html>
<% content_for :title, "This is a test" %>
<h1><%= yield :title %></h1>
<p>This file contains the content that will show up in the "yield" block in the layout...</p>
<% content_for :sidebar do %>
<p>Let's say some secondary content goes here...</p>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment