Browse files

bulk up web site, slim down README

git-svn-id: svn+ssh://rubyforge.org/var/svn/erector/trunk@85 4b8798b9-51f2-4387-91b1-b04f834b421f
  • Loading branch information...
1 parent c71eed3 commit c771796aec0c5a09e738ba951e650018a0587480 alexch committed Apr 25, 2008
View
214 README.txt
@@ -3,20 +3,13 @@
* http://erector.rubyforge.org
* mailto:alex@pivotallabs.com
-
== DESCRIPTION
Erector is a Builder-like view framework, inspired by Markaby but overcoming
some of its flaws. In Erector all views are objects, not template files,
which allows the full power of object-oriented programming (inheritance,
modular decomposition, encapsulation) in views.
-== FEATURES/PROBLEMS:
-
-While Erector is in use on several projects, it is still at a relatively
-early stage. In particular, not all features are documented (although
-the most important ones are).
-
== SYNOPSIS
require 'erector'
@@ -73,210 +66,3 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-== MOTIVATION
-
-Why use Erector? This section will soon become a real essay or blog post,
-but briefly:
-
-* Markaby-style DOM Domain language
-* Your views are real classes, written in a real language, allowing
- * Functional decomposition
- * Inheritance
- * Composition, not partials
- * Well-defined semantics for variables, loops, blocks
- * Dependency injection via constructor params
-* As little magic as possible (e.g. no automagic copying of "assigns" variable from your controller)
-* yield works again (Markaby broke it)
-* Very testable
-* form_for ERB code is craaaaazy (not to mention the quagmire of options vs. htmloptions)
-* Output is streamed, improving performance over string copy
-
-
-== USER DOCUMENTATION
-
-The basic way to construct some HTML/XML with erector is to
-subclass Erector::Widget and implement a render method:
-
- class Hello < Erector::Widget
- def render
- html do
- head do
- title "Hello"
- end
- body do
- text "Hello, "
- b "world!"
- end
- end
- end
- end
- Hello.new.to_s
- #=> <html><head><title>Hello</title></head><body>Hello, <b>world!</b></body></html>
-
-Here are the basics:
-
- element('foo') # <foo></foo>
- empty_element('foo') # <foo />
- html # <html></html> (likewise for other common html tags)
- b "foo" # <b>foo</b>
- text 'foo' # foo
- text '&<>' # &amp;&lt;&gt; (what you generally want, especially
- # if the text came from the user or a database)
- text raw('&<>') # &<> (back door for raw html)
- rawtext('&<>') # &<> (alias for text(raw()))
- html { text foo } # <html>foo</html>
- html "foo" # <html>foo</html>
- html foo # <html>bar</html> (if the method foo returns the string "bar")
- a(:href => 'foo.html') # <a href="foo.html"></a>
- a(:href => 'q?a&b') # <a href="q?a&amp;b"></a> (quotes as for text)
- a(:href => raw('&amp;')) # <a href="&amp;"></a>
- text nbsp("Save Doc") # Save&#160;Doc (turns spaces into non-breaking spaces)
- instruct # <?xml version="1.0" encoding="UTF-8"?>
-
-TODO: document more obscure features like capture, Table, :class => ['one', 'two']
-
-=== Using Erector from Ruby on Rails
-
-Your views are just ruby classes. Your controller instantiates the relevant view and calls render.
-For example:
-
-app/controllers/welcome_controller.rb:
-
- class WelcomeController < ApplicationController
-
- def index
- render :template => 'welcome/show'
- end
-
- end
-
-app/views/welcome/show.rb:
-
- class Views::Welcome::Show < Erector::Widget
-
- def render
- html do
- head do
- title "Welcome page"
- end
-
- body do
- p "Hello, world"
- end
- end
- end
-
- end
-
-For Rails to find these .rb files during render, you must first either copy the erector source to
-vendor/plugins/erector, or add `require 'erector'` to config/environment.rb. You also should delete (or rename)
-any other view files with the same base name that might be getting in the way.
-
-=== Erect
-
-To make Rails integration as smooth as possible, we've written a little tool that will help you
-erect your existing Rails app. The "erect" tool will convert HTML or HTML/ERB into an Erector class.
-It ships as part of the Erector gem, so to try it out, install the gem, then run
-
- erect app/views/foos/*.html.erb
-
-or just
-
- erect app/views
-
-and then delete the original files when you're satisfied.
-
-Here's a little command-line howto for erecting a scaffold Rails app:
-
- rails foo
- cd foo
- script/generate scaffold post title:string body:text published:boolean
-
- erect app/views/posts/*.erb
-
- mate app/views/posts
- sleep 30 # this should be enough time for you to stop drooling
- rm app/views/posts/*.erb
- (echo ""; echo "require 'erector'") >> config/environment.rb
- rake db:migrate
- script/server
- open http://localhost:3000/posts
-
-=== Layout Inheritance
-
-Erector replaces the typical Rails layout mechanism with a more natural construct, the use of inheritance. Want a common
-layout? Just implement a layout superclass and inherit from it. Implement render in the superclass and implement template
-methods in its subclasses. There's one trick you'll need to use this layout for non-erector templates. Here's an example.
-
-`application.rb` - The Erector layout superclass
-
- class Views::Layouts::Application < Erector::Widget
- attr_accessor :content
-
- def render
- html do
- head { } # head content here
- # body content here
- body do
- text content
- end
- end
- end
- end
-
-`application.mab` - The markaby template (adjust for other appropriately templating technologies)
-
- widget = Views::Layouts::Application.new(self)
- widget.content = content_for_layout
- self << widget.to_s
-
-Here the abstract layout widget is used in a concrete fashion by the template-based layout. Normally, the `content` method
-would be implemented by subclassing widgets, but the layout template sets it directly and then calls to_s on the layout widget.
-This allows the same layout to be shared in a backward compatible way.
-
-=== Other ways to call erector
-
-Instead of subclassing Erector::Widget and implementing a render
-method, you can pass a block to Erector::Widget.new. For example:
-
- html = Erector::Widget.new do
- p "Hello, world!"
- end
- html.to_s #=> <p>Hello, world!</p>
-
-This lets you define mini-widgets on the fly.
-
-== DEVELOPER NOTES
-
-* Check out project from rubyforge:
-
- svn co svn+ssh://developername@rubyforge.org/var/svn/erector/trunk erector
-
-* Install gems:
-
- sudo gem install rake rails rspec rubyforge hpricot treetop
-
-* Run specs:
-
- rake
-
-* Check out the available rake tasks:
-
- rake -T
-
-
-=== VERSIONING POLICY
-
-* Versions are of the form major.minor.tiny
-* Tiny revisions fix bugs or documentation
-* Tiny revisions are roughly equal to the svn revision number when they were made
-* Minor revisions add API calls, or change behavior
-* Minor revisions may also remove API calls, but these must be clearly announced in History.txt, with instructions on how to migrate
-* Major revisions are about marketing more than technical needs. We will stay in major version 0 until we're happy taking the "alpha" label off it. And if we ever do a major overhaul of the API, especially one that breaks backwards compatibility, we will probably want to increment the major version.
-* We will not be shy about incrementing version numbers -- if we end up going to version 0.943.67454 then so be it.
-* Developers should attempt to add lines in History.txt to reflect their checkins. These should reflect feature-level changes, not just one line per checkin. The top section of History.txt is used as the Release Notes by the "rake publish" task and will appear on the RubyForge file page.
-* Someone making a release must fill in the version number in History.txt as well as in Rakefile. Note that "rake release" requires a "VERSION=1.2.3" parameter to confirm you're releasing the version you intend.
-* As soon as a release is made and published, the publisher should go into History.txt and make a new section. Since we won't yet know what the next version will be called, the new section will be noted by a single "===" at the top of the file.
-
-
View
7 Rakefile
@@ -5,8 +5,11 @@ require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'spec/rake/spectask'
require './tasks/hoex.rb' # Alex's patched version of Hoe
-require 'lib/erector'
-require 'lib/erector/erect'
+
+dir = File.dirname(__FILE__)
+$: << "#{dir}/lib"
+require "erector"
+require "erector/erect"
GEM_VERSION = Erector::VERSION # defined in lib/erector.rb
GEM_NAME = "erector"
View
2 lib/erector/erect.rb
@@ -109,6 +109,7 @@ def to_html
if widget_class < Erector::Widget
widget = widget_class.new
+ #todo: skip if it's missing a no-arg constructor
dir = output_dir || File.dirname(file)
FileUtils.mkdir_p(dir)
output_file = "#{dir}/#{filename}.html"
@@ -121,7 +122,6 @@ def to_html
end
rescue => e
puts e
- puts
end
end
end
View
4 lib/erector/widget.rb
@@ -14,14 +14,16 @@ def empty_tags
def full_tags
[
'a', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'body',
- 'button', 'caption', 'cite', 'code', 'dd', 'del', 'div', 'dl', 'dt', 'em',
+ 'button', 'caption', 'center', 'cite', 'code',
+ 'dd', 'del', 'div', 'dl', 'dt', 'em',
'fieldset', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'html', 'i',
'iframe', 'ins', 'kbd', 'label', 'legend', 'li', 'map',
'noframes', 'noscript', 'ol', 'optgroup', 'option', 'p', 'param', 'pre',
'samp', 'script', 'select', 'small', 'span', 'strong', 'style', 'sub', 'sup',
'table', 'tbody', 'td', 'textarea', 'th', 'thead', 'title', 'tr', 'tt', 'u', 'ul', 'var'
]
end
+
end
include ActionController::UrlWriter
View
1 web/developers.html
@@ -0,0 +1 @@
+<html><head><title>Erector - Developers</title><link href="erector.css" rel="stylesheet" type="text/css" /></head><body><table><tr><td valign="top"><div class="sidebar"><img align="left" src="erector.jpg" /><br clear="all" /><ul><li><a href="index.html">Home</a></li><li><a href="motivation.html">Motivation</a></li><li><a href="documentation.html">Documentation</a></li><li><a href="developers.html">Developers</a></li></ul><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><center><p>Supported by </p><a href="http://www.pivotallabs.com"><img alt="Pivotal Labs" height="57" src="pivotal.gif" width="158" /></a></center></div></td><td valign="top"><h1 class="title">Erector - Developers</h1><hr /><div class="body"><h2>Check out project from rubyforge:</h2><pre>svn co svn+ssh://developername@rubyforge.org/var/svn/erector/trunk erector</pre><h2>Install gems:</h2><pre>sudo gem install rake rails rspec rubyforge hpricot treetop</pre><h2>Run specs:</h2><pre>rake</pre><h2>Check out the available rake tasks:</h2><pre>rake -T</pre><h2>Sign up for the erector-devel mailing list:</h2><a href="http://rubyforge.org/mailman/listinfo/erector-devel">erector-devel mailing list</a><h2>Versioning and Release Policy</h2><ul><li>Versions are of the form major.minor.tiny</li><li>Tiny revisions fix bugs or documentation</li><li>Tiny revisions are roughly equal to the svn revision number when they were made</li><li>Minor revisions add API calls, or change behavior</li><li>Minor revisions may also remove API calls, but these must be clearly announced in History.txt, with instructions on how to migrate </li><li>Major revisions are about marketing more than technical needs. We will stay in major version 0 until we're happy taking the &quot;alpha&quot; label off it. And if we ever do a major overhaul of the API, especially one that breaks backwards compatibility, we will probably want to increment the major version.</li><li>We will not be shy about incrementing version numbers -- if we end up going to version 0.943.67454 then so be it.</li><li>Developers should attempt to add lines in History.txt to reflect their checkins. These should reflect feature-level changes, not just one line per checkin. The top section of History.txt is used as the Release Notes by the &quot;rake publish&quot; task and will appear on the RubyForge file page.</li></ul><h2>How to push a release</h2><ol><li>Pick a version number. For the build number run 'svn info | grep Revision'</li><li>Look at History.txt and make sure the release notes are up to date. Put the version number on the top line (after the &quot;==&quot;).</li><li>Put the version number in erector.rb as Erector::VERSION.</li><li>Check in with a comment, e.g. 'svn ci -m &quot;release 1.2.3&quot;'</li><li>Run 'rake release VERSION=1.2.3'. (The parameter is to confirm you're releasing the version you intend to.)</li><li>Run 'rake publish_docs web publish_web' cause the docs and site need to be updated, at least with the new version number.</li><li>Immediately go into History.txt and make a new section at the top. Since we won't yet know what the next version will be called, the new section will be noted by a single &quot;==&quot; at the top of the file.</li></ol></div></td></tr></table></body></html>
View
48 web/developers.rb
@@ -0,0 +1,48 @@
+dir = File.dirname(__FILE__)
+require "#{dir}/page"
+require "#{dir}/sidebar"
+
+class Developers < Page
+
+ def render_body
+
+ h2 "Check out project from rubyforge:"
+ pre "svn co svn+ssh://developername@rubyforge.org/var/svn/erector/trunk erector"
+
+ h2 "Install gems:"
+ pre "sudo gem install rake rails rspec rubyforge hpricot treetop"
+
+ h2 "Run specs:"
+ pre "rake"
+
+ h2 "Check out the available rake tasks:"
+ pre "rake -T"
+
+ h2 "Sign up for the erector-devel mailing list:"
+ a("erector-devel mailing list", :href => "http://rubyforge.org/mailman/listinfo/erector-devel")
+
+ h2 "Versioning and Release Policy"
+ ul do
+ li "Versions are of the form major.minor.tiny"
+ li "Tiny revisions fix bugs or documentation"
+ li "Tiny revisions are roughly equal to the svn revision number when they were made"
+ li "Minor revisions add API calls, or change behavior"
+ li "Minor revisions may also remove API calls, but these must be clearly announced in History.txt, with instructions on how to migrate "
+ li "Major revisions are about marketing more than technical needs. We will stay in major version 0 until we're happy taking the \"alpha\" label off it. And if we ever do a major overhaul of the API, especially one that breaks backwards compatibility, we will probably want to increment the major version."
+ li "We will not be shy about incrementing version numbers -- if we end up going to version 0.943.67454 then so be it."
+ li "Developers should attempt to add lines in History.txt to reflect their checkins. These should reflect feature-level changes, not just one line per checkin. The top section of History.txt is used as the Release Notes by the \"rake publish\" task and will appear on the RubyForge file page."
+ end
+
+ h2 "How to push a release"
+ ol do
+ li "Pick a version number. For the build number run 'svn info | grep Revision'"
+ li "Look at History.txt and make sure the release notes are up to date. Put the version number on the top line (after the \"==\")."
+ li "Put the version number in erector.rb as Erector::VERSION."
+ li "Check in with a comment, e.g. 'svn ci -m \"release 1.2.3\"'"
+ li "Run 'rake release VERSION=1.2.3'. (The parameter is to confirm you're releasing the version you intend to.)"
+ li "Run 'rake publish_docs web publish_web' cause the docs and site need to be updated, at least with the new version number."
+ li "Immediately go into History.txt and make a new section at the top. Since we won't yet know what the next version will be called, the new section will be noted by a single \"==\" at the top of the file."
+ end
+ end
+
+end
View
88 web/documentation.html
@@ -0,0 +1,88 @@
+<html><head><title>Erector - Documentation</title><link href="erector.css" rel="stylesheet" type="text/css" /></head><body><table><tr><td valign="top"><div class="sidebar"><img align="left" src="erector.jpg" /><br clear="all" /><ul><li><a href="index.html">Home</a></li><li><a href="motivation.html">Motivation</a></li><li><a href="documentation.html">Documentation</a></li><li><a href="developers.html">Developers</a></li></ul><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><center><p>Supported by </p><a href="http://www.pivotallabs.com"><img alt="Pivotal Labs" height="57" src="pivotal.gif" width="158" /></a></center></div></td><td valign="top"><h1 class="title">Erector - Documentation</h1><hr /><div class="body"><p>Make sure to check out the <a href="rdoc">RDoc Documentation</a> for more details on the API.</p><h2>Contents:</h2><ul><li><a href="#thebasics">The Basics</a></li><li><a href="#apicheatsheet">API Cheatsheet</a></li><li><a href="#usingerectorfromrubyonrails">Using Erector from Ruby on Rails</a></li><li><a href="#erect">Erect: Command-line conversion to and from HTML</a></li><li><a href="#layoutinheritance">Layout Inheritance</a></li><li><a href="#inlinewidgets">Inline Widgets</a></li></ul><a name="thebasics"></a><h2>The Basics</h2><p>The basic way to construct some HTML/XML with erector is to subclass Erector::Widget and implement a render method:</p><pre>class Hello &lt; Erector::Widget
+ def render
+ html do
+ head do
+ title &quot;Hello&quot;
+ end
+ body do
+ text &quot;Hello, &quot;
+ b &quot;world!&quot;
+ end
+ end
+ end
+end
+Hello.new.to_s
+#=&gt; &lt;html&gt;&lt;head&gt;&lt;title&gt;Hello&lt;/title&gt;&lt;/head&gt;&lt;body&gt;Hello, &lt;b&gt;world!&lt;/b&gt;&lt;/body&gt;&lt;/html&gt;
+</pre><a name="apicheatsheet"></a><h2>API Cheatsheet</h2><pre>element('foo') # &lt;foo&gt;&lt;/foo&gt;
+empty_element('foo') # &lt;foo /&gt;
+html # &lt;html&gt;&lt;/html&gt; (likewise for other common html tags)
+b 'foo' # &lt;b&gt;foo&lt;/b&gt;
+text 'foo' # foo
+text '&amp;&lt;&gt;' # &amp;amp;&amp;lt;&amp;gt; (what you generally want, especially
+ # if the text came from the user or a database)
+text raw('&amp;&lt;&gt;') # &amp;&lt;&gt; (back door for raw html)
+rawtext('&amp;&lt;&gt;') # &amp;&lt;&gt; (alias for text(raw()))
+html { text foo } # &lt;html&gt;foo&lt;/html&gt;
+html 'foo' # &lt;html&gt;foo&lt;/html&gt;
+html foo # &lt;html&gt;bar&lt;/html&gt; (if the method foo returns the string &quot;bar&quot;)
+a(:href =&gt; 'foo.html') # &lt;a href=&quot;foo.html&quot;&gt;&lt;/a&gt;
+a(:href =&gt; 'q?a&amp;b') # &lt;a href=&quot;q?a&amp;amp;b&quot;&gt;&lt;/a&gt; (quotes as for text)
+a(:href =&gt; raw('&amp;amp;')) # &lt;a href=&quot;&amp;amp;&quot;&gt;&lt;/a&gt;
+text nbsp('Save Doc') # Save&amp;#160;Doc (turns spaces into non-breaking spaces)
+instruct # &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+</pre><i>TODO: document more obscure features like capture, Table, :class =&gt; ['one', 'two']</i><a name="usingerectorfromrubyonrails"></a><h2>Using Erector from Ruby on Rails</h2><p>Your views are just ruby classes. Your controller instantiates the relevant view and calls render.</p><p>For example:</p><code>app/controllers/welcome_controller.rb:</code><pre>class WelcomeController &lt; ApplicationController
+ def index
+ render :template =&gt; 'welcome/show'
+ end
+end
+</pre><code>app/views/welcome/show.rb:</code><pre>class Views::Welcome::Show &lt; Erector::Widget
+ def render
+ html do
+ head do
+ title &quot;Welcome page&quot;
+ end
+ body do
+ p &quot;Hello, world&quot;
+ end
+ end
+ end
+end
+</pre><p>For Rails to find these .rb files during render, you must first either copy the erector source to <code>vendor/plugins/erector</code>, or add <code>require 'erector'</code> to <code>config/environment.rb</code>. You also should delete (or rename) any other view files with the same base name that might be getting in the way.</p><a name="erect"></a><h2>Erect: Command-line conversion to and from HTML</h2><p> To make Rails integration as smooth as possible, we've written a little tool that will help you
+ erect your existing Rails app. The &quot;erect&quot; tool will convert HTML or HTML/ERB into an Erector class.
+ It ships as part of the Erector gem, so to try it out, install the gem, then run
+</p><pre>erect app/views/foos/*.html.erb</pre><p>or just</p><pre>erect app/views</pre><p>and then delete the original files when you're satisfied.</p><p>Here's a little command-line howto for erecting a scaffold Rails app:</p><pre>rails foo
+cd foo
+script/generate scaffold post title:string body:text published:boolean
+
+erect app/views/posts
+
+mate app/views/posts
+sleep 30 # this should be enough time for you to stop drooling
+rm app/views/posts/*.erb
+(echo &quot;&quot;; echo &quot;require 'erector'&quot;) &gt;&gt; config/environment.rb
+rake db:migrate
+script/server
+open http://localhost:3000/posts
+</pre><a name="layoutinheritance"></a><h2>Layout Inheritance</h2><p>Erector replaces the typical Rails layout mechanism with a more natural construct, the use of inheritance. Want a common
+ layout? Just implement a layout superclass and inherit from it. Implement render in the superclass and implement template
+ methods in its subclasses. There's one trick you'll need to use this layout for non-erector templates. Here's an example.</p><p><code>application.rb</code> - The Erector layout superclass<pre>class Views::Layouts::Application &lt; Erector::Widget
+ attr_accessor :content
+
+ def render
+ html do
+ head { } # head content here
+ # body content here
+ body do
+ text content
+ end
+ end
+ end
+end
+</pre></p><p><code>application.mab</code> - The markaby template (adjust for other appropriately templating technologies)<pre>widget = Views::Layouts::Application.new(self)
+widget.content = content_for_layout
+self &lt;&lt; widget.to_s
+</pre></p><p>Here the abstract layout widget is used in a concrete fashion by the template-based layout. Normally, the <code>content</code> method would be implemented by subclassing widgets, but the layout template sets it directly and then calls <code>to_s</code> on the layout widget. This allows the same layout to be shared in a backward compatible way.</p><a name="inlinewidgets"></a><h2>Inline Widgets</h2><p>Instead of subclassing <code>Erector::Widget</code> and implementing a render method, you can pass a block to <code>Erector::Widget.new</code>. For example:<pre>html = Erector::Widget.new do
+ p &quot;Hello, world!&quot;
+end
+html.to_s #=&gt; &lt;p&gt;Hello, world!&lt;/p&gt;
+</pre>This lets you define mini-widgets on the fly.</p></div></td></tr></table></body></html>
View
233 web/documentation.rb
@@ -0,0 +1,233 @@
+dir = File.dirname(__FILE__)
+require "#{dir}/page"
+require "#{dir}/sidebar"
+
+class Documentation < Page
+ def render_body
+
+ p do
+ text "Make sure to check out the "
+ a "RDoc Documentation", :href => "rdoc"
+ text " for more details on the API."
+ end
+
+ h2 "Contents:"
+ ul do
+ sections.each do |section|
+ li do
+ a section.title, :href => "##{section.href}"
+ end
+ end
+ end
+
+ sections.each do |section|
+ a :name => section.href
+ h2 section.title
+ section.render_to(doc)
+ end
+ end
+
+ def sections
+ [
+ Section.new("The Basics") do
+ p "The basic way to construct some HTML/XML with erector is to subclass Erector::Widget and implement a render method:"
+ pre <<DONE
+class Hello < Erector::Widget
+ def render
+ html do
+ head do
+ title "Hello"
+ end
+ body do
+ text "Hello, "
+ b "world!"
+ end
+ end
+ end
+end
+Hello.new.to_s
+#=> <html><head><title>Hello</title></head><body>Hello, <b>world!</b></body></html>
+DONE
+ end,
+
+ Section.new("API Cheatsheet") do
+ pre <<DONE
+element('foo') # <foo></foo>
+empty_element('foo') # <foo />
+html # <html></html> (likewise for other common html tags)
+b 'foo' # <b>foo</b>
+text 'foo' # foo
+text '&<>' # &amp;&lt;&gt; (what you generally want, especially
+ # if the text came from the user or a database)
+text raw('&<>') # &<> (back door for raw html)
+rawtext('&<>') # &<> (alias for text(raw()))
+html { text foo } # <html>foo</html>
+html 'foo' # <html>foo</html>
+html foo # <html>bar</html> (if the method foo returns the string \"bar\")
+a(:href => 'foo.html') # <a href=\"foo.html\"></a>
+a(:href => 'q?a&b') # <a href=\"q?a&amp;b\"></a> (quotes as for text)
+a(:href => raw('&amp;')) # <a href=\"&amp;\"></a>
+text nbsp('Save Doc') # Save&#160;Doc (turns spaces into non-breaking spaces)
+instruct # <?xml version=\"1.0\" encoding=\"UTF-8\"?>
+DONE
+ i "TODO: document more obscure features like capture, Table, :class => ['one', 'two']"
+ end,
+
+ Section.new("Using Erector from Ruby on Rails") do
+
+ p "Your views are just ruby classes. Your controller instantiates the relevant view and calls render."
+
+ p "For example:"
+
+ code "app/controllers/welcome_controller.rb:"
+ pre <<DONE
+class WelcomeController < ApplicationController
+ def index
+ render :template => 'welcome/show'
+ end
+end
+DONE
+
+ code "app/views/welcome/show.rb:"
+ pre <<DONE
+class Views::Welcome::Show < Erector::Widget
+ def render
+ html do
+ head do
+ title "Welcome page"
+ end
+ body do
+ p "Hello, world"
+ end
+ end
+ end
+end
+DONE
+
+ p do
+ text "For Rails to find these .rb files during render, you must first either copy the erector source to "
+ code "vendor/plugins/erector"
+ text ", or add "
+ code "require 'erector'"
+ text " to "
+ code "config/environment.rb"
+ text ". You also should delete (or rename) any other view files with the same base name that might be getting in the way."
+ end
+
+ end,
+
+ Section.new("Erect: Command-line conversion to and from HTML") do
+
+ p <<DONE
+ To make Rails integration as smooth as possible, we've written a little tool that will help you
+ erect your existing Rails app. The "erect" tool will convert HTML or HTML/ERB into an Erector class.
+ It ships as part of the Erector gem, so to try it out, install the gem, then run
+DONE
+ pre "erect app/views/foos/*.html.erb"
+
+ p "or just"
+
+ pre "erect app/views"
+
+ p "and then delete the original files when you're satisfied."
+
+ p "Here's a little command-line howto for erecting a scaffold Rails app:"
+
+ pre <<DONE
+rails foo
+cd foo
+script/generate scaffold post title:string body:text published:boolean
+
+erect app/views/posts
+
+mate app/views/posts
+sleep 30 # this should be enough time for you to stop drooling
+rm app/views/posts/*.erb
+(echo ""; echo "require 'erector'") >> config/environment.rb
+rake db:migrate
+script/server
+open http://localhost:3000/posts
+DONE
+
+ end,
+
+
+ Section.new("Layout Inheritance") do
+ p "Erector replaces the typical Rails layout mechanism with a more natural construct, the use of inheritance. Want a common
+ layout? Just implement a layout superclass and inherit from it. Implement render in the superclass and implement template
+ methods in its subclasses. There's one trick you'll need to use this layout for non-erector templates. Here's an example."
+
+ p do
+ code "application.rb"
+ text " - The Erector layout superclass"
+ pre <<DONE
+class Views::Layouts::Application < Erector::Widget
+ attr_accessor :content
+
+ def render
+ html do
+ head { } # head content here
+ # body content here
+ body do
+ text content
+ end
+ end
+ end
+end
+DONE
+ end
+
+ p do
+ code "application.mab"
+ text " - The markaby template (adjust for other appropriately templating technologies)"
+ pre <<DONE
+widget = Views::Layouts::Application.new(self)
+widget.content = content_for_layout
+self << widget.to_s
+DONE
+ end
+
+ p do
+ text "Here the abstract layout widget is used in a concrete fashion by the template-based layout. Normally, the "
+ code "content"
+ text " method would be implemented by subclassing widgets, but the layout template sets it directly and then calls "
+ code "to_s"
+ text " on the layout widget. This allows the same layout to be shared in a backward compatible way."
+ end
+ end,
+
+
+ Section.new("Inline Widgets") do
+ p do
+ text "Instead of subclassing "
+ code "Erector::Widget"
+ text " and implementing a render method, you can pass a block to "
+ code "Erector::Widget.new"
+ text ". For example:"
+ pre <<DONE
+html = Erector::Widget.new do
+ p "Hello, world!"
+end
+html.to_s #=> <p>Hello, world!</p>
+DONE
+ text "This lets you define mini-widgets on the fly."
+ end
+ end,
+
+
+ ]
+ end
+end
+
+class Section < Erector::Widget
+ attr_reader :title
+
+ def initialize(title, &block)
+ super(&block)
+ @title = title
+ end
+
+ def href
+ title.split(':').first.gsub(/[^\w]/, '').downcase
+ end
+end
View
50 web/erector.css
@@ -0,0 +1,50 @@
+body, td, a, p {
+ font-family: arial,sans-serif;
+}
+
+img {
+ margin-right: 3em;
+}
+
+li {
+ margin-left: 1.5em;
+ padding-bottom: .5em;
+}
+
+h1 {
+ font-variant: small-caps;
+}
+
+pre {
+ background-color: lemonchiffon;
+ border: 1px solid gray;
+ padding: .5em;
+ padding-left: 2em;
+ margin-right: 6em;
+}
+
+/* sidebar */
+
+div.sidebar {
+ float: left;
+ margin-right: 1em;
+}
+
+.sidebar ul {
+}
+
+.sidebar li {
+ background-color: cadetblue;
+ list-style-type: none;
+ text-align: right;
+ padding: .2em;
+ padding-right: 1em;
+ font-variant: small-caps;
+ margin-bottom: 2px;
+}
+
+.sidebar a, .sidebar a:visited {
+ text-decoration: none;
+ font-weight: bold;
+ color: white;
+}
View
342 web/index.html
@@ -1,24 +1,20 @@
-<html><head><title>Erector</title></head><body><style>img { margin-right: 3em; }</style><img align="left" src="erector.jpg" /><h1>Erector</h1><h2>Erector Links:</h2><ul><li><a href="rdoc">RDoc Documentation</a></li><li><a href="http://rubyforge.org/projects/erector/">RubyForge Project</a></li><li><a href="http://rubyforge.org/scm/?group_id=4797">Subversion</a></li><li><a href="http://rubyforge.org/frs/?group_id=4797">Download</a><span> (current version: 0.2.83)</span></li><li><a href="http://rubyforge.org/mailman/listinfo/erector-devel">erector-devel mailing list</a></li></ul><br clear="all" /><pre>= Erector
-
-* http://erector.rubyforge.org
-* mailto:alex@pivotallabs.com
-
-
-== DESCRIPTION
-
-Erector is a Builder-like view framework, inspired by Markaby but overcoming
-some of its flaws. In Erector all views are objects, not template files,
-which allows the full power of object-oriented programming (inheritance,
-modular decomposition, encapsulation) in views.
-
-== FEATURES/PROBLEMS:
-
-While Erector is in use on several projects, it is still at a relatively
-early stage. In particular, not all features are documented (although
-the most important ones are).
-
-== SYNOPSIS
-
+<html><head><title>Erector - Home</title><link href="erector.css" rel="stylesheet" type="text/css" /></head><body><table><tr><td valign="top"><div class="sidebar"><img align="left" src="erector.jpg" /><br clear="all" /><ul><li><a href="index.html">Home</a></li><li><a href="motivation.html">Motivation</a></li><li><a href="documentation.html">Documentation</a></li><li><a href="developers.html">Developers</a></li></ul><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><center><p>Supported by </p><a href="http://www.pivotallabs.com"><img alt="Pivotal Labs" height="57" src="pivotal.gif" width="158" /></a></center></div></td><td valign="top"><h1 class="title">Erector - Home</h1><hr /><div class="body"><h2>Links:</h2><ul><li><a href="http://rubyforge.org/frs/?group_id=4797">Download</a><span> (current version: 0.2.83)</span></li><li><a href="rdoc">RDoc Documentation</a></li><li><a href="http://rubyforge.org/projects/erector/">RubyForge Project</a></li><li><a href="http://rubyforge.org/scm/?group_id=4797">Subversion Repository</a></li><li><a href="http://rubyforge.org/mailman/listinfo/erector-devel">erector-devel mailing list</a></li></ul><hr /><h1>Readme</h1><ul>
+<li>http://erector.rubyforge.org
+
+</li>
+<li>mailto:alex@pivotallabs.com
+
+</li>
+</ul>
+<h2>DESCRIPTION</h2>
+<p>
+Erector is a Builder-like view framework, inspired by Markaby but
+overcoming some of its flaws. In Erector all views are objects, not
+template files, which allows the full power of object-oriented programming
+(inheritance, modular decomposition, encapsulation) in views.
+</p>
+<h2>SYNOPSIS</h2>
+<pre>
require 'erector'
class Hello &lt; Erector::Widget
@@ -28,256 +24,64 @@
end
end
end
-
-== REQUIREMENTS
-
-The gem depends on hoe and rake, although this is just for building
-erector (those who just use erector won't need these).
-
-== INSTALL
-
+</pre>
+<h2>REQUIREMENTS</h2>
+<p>
+The gem depends on hoe and rake, although this is just for building erector
+(those who just use erector won&#8217;t need these).
+</p>
+<h2>INSTALL</h2>
+<p>
To install as a gem:
-
-* sudo gem install erector
-
-Then add &quot;require 'erector'&quot; to any files which need erector.
-
+</p>
+<ul>
+<li>sudo gem install erector
+
+</li>
+</ul>
+<p>
+Then add &quot;require &#8216;erector&#8217;&quot; to any files which need
+erector.
+</p>
+<p>
To install as a Rails plugin:
-
-* Copy the erector source to vendor/plugins/erector in your Rails directory.
-
-When installing this way, erector is automatically available to your Rails code
-(no require directive is needed).
-
-== LICENSE:
-
+</p>
+<ul>
+<li>Copy the erector source to vendor/plugins/erector in your Rails directory.
+
+</li>
+</ul>
+<p>
+When installing this way, erector is automatically available to your Rails
+code (no require directive is needed).
+</p>
+<h2>LICENSE:</h2>
+<p>
(The MIT License)
-
-Copyright (c) 2007-8 Pivotal Labs
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-&quot;Software&quot;), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
+</p>
+<p>
+Copyright &#169; 2007-8 Pivotal Labs
+</p>
+<p>
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+&quot;Software&quot;), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to the
+following conditions:
+</p>
+<p>
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+</p>
+<p>
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-== MOTIVATION
-
-Why use Erector? This section will soon become a real essay or blog post,
-but briefly:
-
-* Markaby-style DOM Domain language
-* Your views are real classes, written in a real language, allowing
- * Functional decomposition
- * Inheritance
- * Composition, not partials
- * Well-defined semantics for variables, loops, blocks
- * Dependency injection via constructor params
-* As little magic as possible (e.g. no automagic copying of &quot;assigns&quot; variable from your controller)
-* yield works again (Markaby broke it)
-* Very testable
-* form_for ERB code is craaaaazy (not to mention the quagmire of options vs. htmloptions)
-* Output is streamed, improving performance over string copy
-
-
-== USER DOCUMENTATION
-
-The basic way to construct some HTML/XML with erector is to
-subclass Erector::Widget and implement a render method:
-
- class Hello &lt; Erector::Widget
- def render
- html do
- head do
- title &quot;Hello&quot;
- end
- body do
- text &quot;Hello, &quot;
- b &quot;world!&quot;
- end
- end
- end
- end
- Hello.new.to_s
- #=&gt; &lt;html&gt;&lt;head&gt;&lt;title&gt;Hello&lt;/title&gt;&lt;/head&gt;&lt;body&gt;Hello, &lt;b&gt;world!&lt;/b&gt;&lt;/body&gt;&lt;/html&gt;
-
-Here are the basics:
-
- element('foo') # &lt;foo&gt;&lt;/foo&gt;
- empty_element('foo') # &lt;foo /&gt;
- html # &lt;html&gt;&lt;/html&gt; (likewise for other common html tags)
- b &quot;foo&quot; # &lt;b&gt;foo&lt;/b&gt;
- text 'foo' # foo
- text '&amp;&lt;&gt;' # &amp;amp;&amp;lt;&amp;gt; (what you generally want, especially
- # if the text came from the user or a database)
- text raw('&amp;&lt;&gt;') # &amp;&lt;&gt; (back door for raw html)
- rawtext('&amp;&lt;&gt;') # &amp;&lt;&gt; (alias for text(raw()))
- html { text foo } # &lt;html&gt;foo&lt;/html&gt;
- html &quot;foo&quot; # &lt;html&gt;foo&lt;/html&gt;
- html foo # &lt;html&gt;bar&lt;/html&gt; (if the method foo returns the string &quot;bar&quot;)
- a(:href =&gt; 'foo.html') # &lt;a href=&quot;foo.html&quot;&gt;&lt;/a&gt;
- a(:href =&gt; 'q?a&amp;b') # &lt;a href=&quot;q?a&amp;amp;b&quot;&gt;&lt;/a&gt; (quotes as for text)
- a(:href =&gt; raw('&amp;amp;')) # &lt;a href=&quot;&amp;amp;&quot;&gt;&lt;/a&gt;
- text nbsp(&quot;Save Doc&quot;) # Save&amp;#160;Doc (turns spaces into non-breaking spaces)
- instruct # &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
-
-TODO: document more obscure features like capture, Table, :class =&gt; ['one', 'two']
-
-=== Using Erector from Ruby on Rails
-
-Your views are just ruby classes. Your controller instantiates the relevant view and calls render.
-For example:
-
-app/controllers/welcome_controller.rb:
-
- class WelcomeController &lt; ApplicationController
-
- def index
- render :template =&gt; 'welcome/show'
- end
-
- end
-
-app/views/welcome/show.rb:
-
- class Views::Welcome::Show &lt; Erector::Widget
-
- def render
- html do
- head do
- title &quot;Welcome page&quot;
- end
-
- body do
- p &quot;Hello, world&quot;
- end
- end
- end
-
- end
-
-For Rails to find these .rb files during render, you must first either copy the erector source to
-vendor/plugins/erector, or add `require 'erector'` to config/environment.rb. You also should delete (or rename)
-any other view files with the same base name that might be getting in the way.
-
-=== Erect
-
-To make Rails integration as smooth as possible, we've written a little tool that will help you
-erect your existing Rails app. The &quot;erect&quot; tool will convert HTML or HTML/ERB into an Erector class.
-It ships as part of the Erector gem, so to try it out, install the gem, then run
-
- erect app/views/foos/*.html.erb
-
-or just
-
- erect app/views
-
-and then delete the original files when you're satisfied.
-
-Here's a little command-line howto for erecting a scaffold Rails app:
-
- rails foo
- cd foo
- script/generate scaffold post title:string body:text published:boolean
-
- erect app/views/posts/*.erb
-
- mate app/views/posts
- sleep 30 # this should be enough time for you to stop drooling
- rm app/views/posts/*.erb
- (echo &quot;&quot;; echo &quot;require 'erector'&quot;) &gt;&gt; config/environment.rb
- rake db:migrate
- script/server
- open http://localhost:3000/posts
-
-=== Layout Inheritance
-
-Erector replaces the typical Rails layout mechanism with a more natural construct, the use of inheritance. Want a common
-layout? Just implement a layout superclass and inherit from it. Implement render in the superclass and implement template
-methods in its subclasses. There's one trick you'll need to use this layout for non-erector templates. Here's an example.
-
-`application.rb` - The Erector layout superclass
-
- class Views::Layouts::Application &lt; Erector::Widget
- attr_accessor :content
-
- def render
- html do
- head { } # head content here
- # body content here
- body do
- text content
- end
- end
- end
- end
-
-`application.mab` - The markaby template (adjust for other appropriately templating technologies)
-
- widget = Views::Layouts::Application.new(self)
- widget.content = content_for_layout
- self &lt;&lt; widget.to_s
-
-Here the abstract layout widget is used in a concrete fashion by the template-based layout. Normally, the `content` method
-would be implemented by subclassing widgets, but the layout template sets it directly and then calls to_s on the layout widget.
-This allows the same layout to be shared in a backward compatible way.
-
-=== Other ways to call erector
-
-Instead of subclassing Erector::Widget and implementing a render
-method, you can pass a block to Erector::Widget.new. For example:
-
- html = Erector::Widget.new do
- p &quot;Hello, world!&quot;
- end
- html.to_s #=&gt; &lt;p&gt;Hello, world!&lt;/p&gt;
-
-This lets you define mini-widgets on the fly.
-
-== DEVELOPER NOTES
-
-* Check out project from rubyforge:
-
- svn co svn+ssh://developername@rubyforge.org/var/svn/erector/trunk erector
-
-* Install gems:
-
- sudo gem install rake rails rspec rubyforge hpricot treetop
-
-* Run specs:
-
- rake
-
-* Check out the available rake tasks:
-
- rake -T
-
-
-=== VERSIONING POLICY
-
-* Versions are of the form major.minor.tiny
-* Tiny revisions fix bugs or documentation
-* Tiny revisions are roughly equal to the svn revision number when they were made
-* Minor revisions add API calls, or change behavior
-* Minor revisions may also remove API calls, but these must be clearly announced in History.txt, with instructions on how to migrate
-* Major revisions are about marketing more than technical needs. We will stay in major version 0 until we're happy taking the &quot;alpha&quot; label off it. And if we ever do a major overhaul of the API, especially one that breaks backwards compatibility, we will probably want to increment the major version.
-* We will not be shy about incrementing version numbers -- if we end up going to version 0.943.67454 then so be it.
-* Developers should attempt to add lines in History.txt to reflect their checkins. These should reflect feature-level changes, not just one line per checkin. The top section of History.txt is used as the Release Notes by the &quot;rake publish&quot; task and will appear on the RubyForge file page.
-* Someone making a release must fill in the version number in History.txt as well as in Rakefile. Note that &quot;rake release&quot; requires a &quot;VERSION=1.2.3&quot; parameter to confirm you're releasing the version you intend.
-* As soon as a release is made and published, the publisher should go into History.txt and make a new section. Since we won't yet know what the next version will be called, the new section will be noted by a single &quot;===&quot; at the top of the file.
-
-
-</pre></body></html>
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+</p>
+</div></td></tr></table></body></html>
View
64 web/index.rb
@@ -1,51 +1,41 @@
dir = File.dirname(__FILE__)
require "#{dir}/page"
+require "#{dir}/sidebar"
+
+require "rdoc/rdoc"
+
+require 'rdoc/markup/simple_markup'
+require 'rdoc/markup/simple_markup/to_html'
class Index < Page
def initialize
- super
- @title = "Erector"
+ super("Home")
end
-
+
def render_body
- style do
- text 'img { margin-right: 3em; }'
- end
- img :src => 'erector.jpg', :align => 'left'
- h1 do
- text 'Erector'
- end
-
- h2 "Erector Links:"
+
+ h2 "Links:"
ul do
li do
- a :href => 'rdoc' do
- text 'RDoc Documentation'
- end
- end
- li do
- a :href => 'http://rubyforge.org/projects/erector/' do
- text 'RubyForge Project'
- end
- end
- li do
- a :href => 'http://rubyforge.org/scm/?group_id=4797' do
- text 'Subversion'
- end
- end
- li do
- a :href => 'http://rubyforge.org/frs/?group_id=4797' do
- text 'Download'
- end
+ a('Download', :href => 'http://rubyforge.org/frs/?group_id=4797')
span " (current version: #{Erector::VERSION})"
end
- li do
- a "erector-devel mailing list", :href => "http://rubyforge.org/mailman/listinfo/erector-devel"
- end
- end
- br :clear => "all"
- pre do
- text File.read("#{File.dirname(__FILE__)}/../README.txt")
+ li { a('RDoc Documentation', :href =>'rdoc') }
+ li { a('RubyForge Project', :href => 'http://rubyforge.org/projects/erector/') }
+ li { a('Subversion Repository', :href => 'http://rubyforge.org/scm/?group_id=4797') }
+ li { a("erector-devel mailing list", :href => "http://rubyforge.org/mailman/listinfo/erector-devel") }
end
+
+ hr
+ h1 "Readme"
+
+ readme = File.read("#{File.dirname(__FILE__)}/../README.txt")
+ readme.gsub!(/^\= Erector/, '')
+ p = SM::SimpleMarkup.new
+ h = SM::ToHtml.new
+
+ rawtext p.convert(readme, h)
+
end
end
+
View
1 web/motivation.html
@@ -0,0 +1 @@
+<html><head><title>Erector - Motivation</title><link href="erector.css" rel="stylesheet" type="text/css" /></head><body><table><tr><td valign="top"><div class="sidebar"><img align="left" src="erector.jpg" /><br clear="all" /><ul><li><a href="index.html">Home</a></li><li><a href="motivation.html">Motivation</a></li><li><a href="documentation.html">Documentation</a></li><li><a href="developers.html">Developers</a></li></ul><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><center><p>Supported by </p><a href="http://www.pivotallabs.com"><img alt="Pivotal Labs" height="57" src="pivotal.gif" width="158" /></a></center></div></td><td valign="top"><h1 class="title">Erector - Motivation</h1><hr /><div class="body"><h1>Why use Erector?</h1><div>Briefly...</div><ul><li>Markaby-style DOM builder domain language</li><li>Your views are real classes, written in a real language, allowing<ul><li>Functional decomposition</li><li>Inheritance</li><li>Composition, not partials</li><li>Well-defined semantics for variables, loops, blocks</li><li>Dependency injection via constructor params</li></ul></li><li>As little magic as possible (e.g. no automagic copying of &quot;assigns&quot; variable from your controller)</li><li>yield works again (Markaby broke it)</li><li>Very testable</li><li>form_for ERB code is craaaaazy (not to mention the quagmire of options vs. htmloptions)</li><li>Output is streamed, improving performance over string copy</li></ul></div></td></tr></table></body></html>
View
33 web/motivation.rb
@@ -0,0 +1,33 @@
+dir = File.dirname(__FILE__)
+require "#{dir}/page"
+require "#{dir}/sidebar"
+
+class Motivation < Page
+
+ def render_body
+ h1 "Why use Erector?"
+
+ div "Briefly..."
+
+ ul do
+ li 'Markaby-style DOM builder domain language'
+ li do
+ text 'Your views are real classes, written in a real language, allowing'
+ ul do
+ li 'Functional decomposition'
+ li 'Inheritance'
+ li 'Composition, not partials'
+ li 'Well-defined semantics for variables, loops, blocks'
+ li 'Dependency injection via constructor params'
+ end
+ end
+ li 'As little magic as possible (e.g. no automagic copying of "assigns" variable from your controller)'
+ li 'yield works again (Markaby broke it)'
+ li 'Very testable'
+ li 'form_for ERB code is craaaaazy (not to mention the quagmire of options vs. htmloptions)'
+ li 'Output is streamed, improving performance over string copy'
+ end
+ end
+
+end
+
View
2 web/page.html
@@ -1 +1 @@
-<html><head><title></title></head><body></body></html>
+<html><head><title>Erector - Page</title><link href="erector.css" rel="stylesheet" type="text/css" /></head><body><table><tr><td valign="top"><div class="sidebar"><img align="left" src="erector.jpg" /><br clear="all" /><ul><li><a href="index.html">Home</a></li><li><a href="motivation.html">Motivation</a></li><li><a href="documentation.html">Documentation</a></li><li><a href="developers.html">Developers</a></li></ul><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><center><p>Supported by </p><a href="http://www.pivotallabs.com"><img alt="Pivotal Labs" height="57" src="pivotal.gif" width="158" /></a></center></div></td><td valign="top"><h1 class="title">Erector - Page</h1><hr /><div class="body"></div></td></tr></table></body></html>
View
28 web/page.rb
@@ -1,11 +1,35 @@
class Page < Erector::Widget
+ def initialize(title = self.class.name, selection = title.downcase)
+ super
+ @title = title
+ @selection = selection
+ end
+
def render
html do
head do
- title @title
+ title "Erector - #{@title}"
+ link :rel => 'stylesheet', :type => "text/css", :href => "erector.css"
end
body do
- render_body
+ table do
+ tr do
+ td "valign" => "top" do
+ Sidebar.new(@selection).render_to(doc)
+ end
+ td "valign" => "top" do
+ h1 :class => "title" do
+ text "Erector - #{@title}"
+ end
+
+ hr
+
+ div :class => "body" do
+ render_body
+ end
+ end
+ end
+ end
end
end
end
View
BIN web/pivotal.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
1 web/sidebar.html
@@ -0,0 +1 @@
+<div class="sidebar"><img align="left" src="erector.jpg" /><br clear="all" /><ul><li><a href="index.html">Home</a></li><li><a href="motivation.html">Motivation</a></li><li><a href="documentation.html">Documentation</a></li><li><a href="developers.html">Developers</a></li></ul><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><center><p>Supported by </p><a href="http://www.pivotallabs.com"><img alt="Pivotal Labs" height="57" src="pivotal.gif" width="158" /></a></center></div>
View
30 web/sidebar.rb
@@ -0,0 +1,30 @@
+class Sidebar < Erector::Widget
+ def initialize(current_page = nil)
+ super
+ @current_page = current_page
+ end
+
+ def render
+
+ div :class => "sidebar" do
+
+ img :src => 'erector.jpg', :align => 'left'
+ br :clear => "all"
+ ul do
+ li { a "Home", :href => 'index.html' }
+ li { a "Motivation", :href => 'motivation.html' }
+ li { a "Documentation", :href => 'documentation.html' }
+ li { a "Developers", :href => 'developers.html' }
+ end
+
+ 10.times { br }
+ center do
+ p "Supported by "
+ a :href => "http://www.pivotallabs.com" do
+ img :src => "pivotal.gif", :width => 158, :height => 57, :alt => "Pivotal Labs"
+ end
+ end
+ end
+ end
+
+end

0 comments on commit c771796

Please sign in to comment.