SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: What's ERB?

  1. #1
    SitePoint Addict
    Join Date
    Sep 2009
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question What's ERB?

    I'm looking up how HAML works and I've found documentation that assumes an understanding of ERB. I know nothing other than it relates to Ruby. I also know very little about ruby. I don't deal with server side languages often but when I do it's PHP. Can anyone give me a summary of ERB? I'd like to start working with HAML and so I think I need to understand a few things first.

  2. #2
    SitePoint Zealot
    Join Date
    Feb 2003
    Location
    Akron, OH, USA
    Posts
    106
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    ERB is Embedded Ruby. It is often used to embed Ruby code in an HTML document within Rails.

    HAML is a RubyGem which is essentially the same thing as ERB but with a different syntax.

    Here is a sample of ERB:
    Code:
    <section class=”container”>
      <h1><%= post.title %></h1>
      <h2><%= post.subtitle %></h2>
      <div class=”content”>
        <%= post.content %>
      </div>
    </section>
    Here is the same code converted to HAML:
    Code:
    %section.container
      %h1= post.title
      %h2= post.subtitle
      .content
        = post.content


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •