Skip to content

Instantly share code, notes, and snippets.

@abloom
Created March 9, 2009 21:18
Show Gist options
  • Select an option

  • Save abloom/76484 to your computer and use it in GitHub Desktop.

Select an option

Save abloom/76484 to your computer and use it in GitHub Desktop.
module ApplicationHelper
def content_block(name, &block)
override = yield(name)
return override unless override.blank?
return capture(block)
end
end
<html>
<head>
<title>
<% content_block(:title) do %>
Default Title
<% end %>
</title>
</head>
<body>
<%= yield %>
</body>
</html>
<% content_for(:title) do %>
Custom Title
<% end %>
Regular body content here will end up in the lone "yield" in the template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment