Skip to content

Instantly share code, notes, and snippets.

@mpen
Created October 14, 2009 23:42
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 mpen/210500 to your computer and use it in GitHub Desktop.
Save mpen/210500 to your computer and use it in GitHub Desktop.
Rails yield / content_for
<html>
<head>
<%= yield :head %>
</head>
<body>
<%= yield %>
<%= yield :javascript %>
</body>
</html>
<% content_for :head do %>
<%= stylesheet_link_tag 'style' %>
<% end %>
<% content_for :javascript do %>
<%= javascript_include_tag 'prototype' %>
<% end %>
<% content_for :javascript do %>
<% javascript_tag do %>
alert('...')
<% end %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment