spacer
spacer
spacer

Erector is a Builder-like view framework for Ruby, inspired by Markaby.

In Erector all views are objects, not template files, which allows the full power of object-oriented programming (inheritance, modular decomposition, encapsulation) in views.

Examples

require 'erector'

class Hello < Erector::Widget
  def content
    html {
      head {
        title "Hello"
      }
      body {
        h1.heading! "Message:"
        text "Hello, "
        b.big @target
        text "!"
      }
    }
  end
end

Hello.new(:target => 'world').to_html
<html>
  <head>
    <title>Hello</title>
  </head>
  <body>
    <h1 id="heading">Message:</h1>
    Hello, <b class="big">world</b>!
  </body>
</html>
include Erector::Mixin
erector { div "love", :class => "big" }
<div class="big">love</div>
require 'erector'
class Logo < Erector::Widget
  def content
    div.logo {
      a(:href => "index.html") {
        img.logo :src => 'erector.jpg',
          :height => 323, 
          :width => 287
      }
    }
  end
end
<div class="logo">
  <a class="index.html">
    <img class="logo" "323" 
      src="/img/spacer.gif"> 
              

Current version: 0.9.0

spacer
Erector is an open source project released under the MIT license.
Its initial development was sponsored by Pivotal Labs.
Not affiliated with or sponsored by the makers of Erector or Meccano toys.
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.