Thursday, April 03, 2008

Draft of Erector talk

I'm giving a talk on erector in about a week at the Washington, DC Ruby User's Group. Here's a draft of my talk; please provide feedback so I can improve the talk (for example, as comments at the bottom of this page).

Ruby's flexible and minimal syntax makes it well-suited to writing libraries for various tasks

Erector applies that to HTML (or XML) rendering

(start up erector in script/console and go through the following examples)

class Foo < Erector::Widget
def render
end do
end.to_s do
p "foo"
end.to_s do
text "hello"
end.to_s do
p do
text "hello"
b "world"
end.to_s do
a :href => "a.html" do
text "world"
end.to_s do
a "world", :href => "a.html" do
end.to_s do
text '<>&'

Hooking erector to rails:

class WelcomeController <

def index
render :text =>


Structuring views with the usual Ruby techniques: especially inheritance and methods

Responsibilities of a view mechanism:

  • quote output

  • balance start/end tags

Comparison with ERB and Markaby, quoting:

ERB: no, must call h

Markaby: for strings, not blocks

Erector: yes*

* except when you call raw

Comparison with ERB and Markaby, tag balancing:

ERB: no

Markaby: yes

Erector: yes*

* except when you call raw

Comparison with ERB and Markaby, subpages:

ERB: partials, helpers

Markaby: partials, helpers

Erector: inheritance, methods

Similar libraries in other languages:

If there is time:

  • Calling helpers from erector

  • Writing helpers in erector


Brian Slesinsky said...

Alas, mentioning Webiyo might not be doing your audience much of a favor. There's little point in getting people hooked on abandonware.

Jim Kingdon said...

Sorry, Brian, but even if you have abandoned webiyo I haven't (although I'll admit I haven't had a need for it lately). Although if there's another similar library in Java (or other languages), I'd be glad to link to those instead.