Created
April 21, 2009 07:08
-
-
Save btakita/98993 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
class SiteWidget < Erector::Widget | |
class << self | |
def tag(name, value=nil, &implentation) | |
raise(ArgumentError, "You cannot have both a value and an implentation") if value && implentation | |
if implentation | |
define_method(name, &implentation) | |
else | |
define_method(name) {value} | |
end | |
end | |
end | |
def content | |
html do | |
head do | |
title | |
end | |
body do | |
div :class => :header do | |
h1 title_text | |
end | |
div :class => :navigation do | |
end | |
article | |
end | |
end | |
end | |
alias_method :render, :content | |
def title | |
element(:title, title_text) | |
end | |
tag :title_text, "" | |
def article | |
div(:class => :article) {article_content} | |
end | |
tag :article_content, "" | |
end |
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
class SiteWidget < Erector::Widget | |
class << self | |
def tag(name, value=nil, &implentation) | |
raise(ArgumentError, "You cannot have both a value and an implentation") if value && implentation | |
if implentation | |
define_method(name, &implentation) | |
else | |
define_method(name) {value} | |
end | |
end | |
end | |
def write | |
html do | |
head do | |
title | |
end | |
body do | |
div :class => :header do | |
h1 title_text | |
end | |
div :class => :navigation do | |
end | |
article | |
end | |
end | |
end | |
alias_method :render, :write | |
def title | |
element(:title, title_text) | |
end | |
tag :title_text, "" | |
def article | |
div(:class => :article) {article_content} | |
end | |
tag :article_content, "" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment