Articles tagged 'haml'

  • Replacing ERb with HAML on your Rails application generators

    January 5, 2012

    This post was originally published in the Rambling Labs Blog on January 5, 2012.

    As you may know, we’ve been using HAML lately for our views.

    Since I don’t plan to use ERb for my views anytime soon, I want HAML to fit in as smoothly as possible. Luckily, there is a way to replace ERb as the default generated view.

    Just add this line to your Gemfile:

    gem 'haml-rails'

    And you should be good to go!

    Now, when you run rails generate controller test method_one method_two, you should see something like this:

          # ...
          invoke haml
          create app/views/test
          create app/views/test/method_one.html.haml
          create app/views/test/method_two.html.haml
          # ...

    Way easier than what I thought it would be. But you know, that’s…

    Continue Reading →

  • Writing elegant HTML with HAML

    January 4, 2012

    This post was originally published in the Rambling Labs Blog on January 4, 2012.

    Another cool thing that we learned while building the new Rambling Labs site was HAML. It’s a markup language that is based on the premise that ‘Markup should be beautiful’, in their own words.

    It’s very easy to install, just add gem 'haml' to your Gemfile and run bundle install. To use it, replace your view_name.html.erb file with a view_name.html.haml file.

    Like SASS and CoffeeScript, to achieve the beauty it professes, HAML uses indentation to determine what it should do next. This means, and you guessed it, that it writes beautifully.

    Compare this ERb file:

    <div id="single_post">
      <h2 class="post_title"><%= link_to post.title, post %></h2>

    Continue Reading →