stonean

trying to be better than I was yesterday

RuHL

If you like and use RuHL, please vote for it on RubyTrends

Available on gemcutter

The gist comparing Erb, Mustache and RuHL

What is RuHL?

RuHL is an HTML based template engine that thinks code in views is bad, presenters are good and testing your views should be easy.

I’ve recently come across the terminology “Attribute language” which seems to be a more accurate description.

Here’s a quick example:

<html>
  <body>
    <p data-ruhl="say_hello"/>
  </body>
</html>

There is a method defined as (available to self):

def say_hello
  "Hello World"
end

Then you call:

Ruhl::Engine.new(File.read(‘hello_world.ruhl’)).render(self)

The result would be:

<html>
  <body>
    <p>Hello World</p>
  </body>
</html>

This is obviously a simple example, but I just wanted to give you an idea of what RuHL is.

Philosophy

RuHL’s mission is to reduce the amount of code used in your view. I believe code in views is a bad practice. The restrictions enforced by RuHL are intended to guide the user to better code architecture by promoting presenters. An unplanned revelation of this premise was that this makes testing your application easier. More on this later.

Index

  1. The Options
  2. The Reserved Words
  3. Sinatra
  4. Rails
  5. RSpec

Github

Yes, it’s on Github.

Lighthouse

I’ve created a Lighthouse account to track issues. Please let me know what I can do to make RuHL your view system of choice.

License

RuHL is free to use under the terms of the MIT license.

Copyright © 2009 Andrew Stone

Copyright © 2010 stonean. All rights reserved.
Powered by Thoth.