Fork me on GitHub

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.


require 'erector'

class Hello < Erector::Widget
  def content
    html {
      head {
        title "Hello"
      body {
        h1.heading! "Message:"
        text "Hello, "
        b.big @target
        text "!"
end => 'world').to_html
    <h1 id="heading">Message:</h1>
    Hello, <b class="big">world</b>!
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
<div class="logo">
  <a href="index.html">
    <img class="logo" height="323" 
      src="erector.jpg" width="287" />

Current version: 0.10.0