Created
May 24, 2010 10:17
-
-
Save markevans/411722 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helper file | |
class Block < BlockHelpers::Base | |
def initialize(opts={}) | |
@opts = opts | |
end | |
def display(body) | |
content_tag :div, body, :class => "block #{@opts[:class]}" | |
end | |
class Head < BlockHelpers::Base | |
def display(body) | |
content_tag :div, body, :class => 'block_head' | |
end | |
end | |
class Content < BlockHelpers::Base | |
def display(body) | |
content_tag :div, body, :class => 'block_content' | |
end | |
end | |
end | |
# Views | |
<% block :class => 'centre login' do |b| %> | |
<% b.head do |bh| %> | |
CONTENT FOR BLOCK_HEAD | |
<% end %> | |
<% b.content do |bc| %> | |
CONTENT FOR BLOCK_CONTENT | |
<% end %> | |
<% end %> | |
# Output | |
<div class="block centre login"> | |
<div class="block_head"> | |
CONTENT FOR BLOCK_HEAD | |
</div> | |
<div class="block_content"> | |
CONTENT FOR BLOCK_CONTENT | |
</div> | |
</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment