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.

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:

<[B]section class[B]=”container[B]”>
  <[B]h1><[B]%= post.title %></[B]h1>
  <[B]h2><[B]%= post.subtitle %></[B]h2>
  <[B]div class[B]=”content[B]”>
    <[B]%= post.content %>
  </[B]div>
</[B]section>[/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B]

Here is the same code converted to HAML:


%[B]section.[B]container
  %[B]h1[B]= post.title
  %[B]h2[B]= post.subtitle
  .[B]content
    [B]= post.content[/B][/B][/B][/B][/B][/B][/B][/B]