Skip to content

Instantly share code, notes, and snippets.

@btakita
Created April 21, 2009 07:08
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 btakita/98993 to your computer and use it in GitHub Desktop.
Save btakita/98993 to your computer and use it in GitHub Desktop.
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
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