Parkaby: Faster HTML Generation with Ruby

Why’s Markaby is a really convenient bit of Ruby for generating HTML in your applications, rather than having to fiddle about with string interpolation or ERb, tangling together HTML and Ruby.

However, Markaby can be slow compared with other options like Erubis or HAML. Magnus Holm has been working on an alternative solution called Parkaby, which uses ParseTree for improved performance (coming out up to 20 times faster than Markaby in Magnus’s tests).  Parkaby uses near-identical syntax to Markaby, so you still get to write beautiful ruby code for building your HTML.

Parkaby {
    html {
      head {
        title "happy title"
      }
      body {
        h1 "happy heading"
        a "a link", "href" => "url"
      }
    }
  }

Magnus admits that Parkaby is currently only experimental, and that there’s room for more optimization, but I think he might be onto something. Parkaby is available on Github.

Leave a Reply

Your email address will not be published. Required fields are marked *