Question: Is it possible convert the ERB code below to HAML?

**ERB**

```
<div class="users">    
  <div class="row">
    <% i = 0 %>
    <% @users.each do |user| %>
      <span><%= @user.name %></span>
      <% if i % 4 == 0 %>
        </div> <!-- Close div .row -->
        <div class="row"> <!-- Open new div .row -->
      <% end %>
      <% i += 1 %>
    <% end %>
  </div> <!-- Close div .row -->
</div> <!-- Close div .users -->

```

**RESULT** (HTML)

```
<div class="users">    
  <div class="row">
    <span>User Name 1</span>
    <span>User Name 2</span>
    <span>User Name 3</span>
    <span>User Name 4</span>
  </div> <!-- Close div .row -->
  <div class="row"> <!-- Open new div .row -->
    <span>User Name 5</span>
    <span>User Name 6</span>
    <span>User Name 7</span>
    <span>User Name 8</span>
  </div> <!-- Close div .row -->
  <div class="row"> <!-- Open new div .row -->
    <span>User Name 9</span>
    <span>User Name 10</span>
    <span>User Name 11</span>
    <span>User Name 12</span>
  </div> <!-- Close div .row -->
</div> <!-- Close div .users -->

```

Answer: 
Here's the code for `GetOrdinal` for `SqlDataReader`, .NET 4.0, pulled using ILSpy.

```
public override int GetOrdinal(string name)
{
    SqlStatistics statistics = null;
    int ordinal;
    try
    {
        statistics = SqlStatistics.StartTimer(this.Statistics);
        if (this._fieldNameLookup == null)
        {
            if (this.MetaData == null)
            {
                throw SQL.InvalidRead();
            }
            this._fieldNameLookup = new FieldNameLookup(this, this._defaultLCID);
        }
        ordinal = this._fieldNameLookup.GetOrdinal(name);
    }
    finally
    {
        SqlStatistics.StopTimer(statistics);
    }
    return ordinal;
}

```

As you can see, there's no additional database access. `FieldNameLookup` uses a `Hashtable` to store the field names, and is cached after it is loaded the first time `GetOrdinal` is called. So the `GetOrdinal` calls will add a very small amount of overhead for the lookups done through `FieldNameLookup`, and the `SqlStatistics` calls may also add a little bit of overhead (although probably not much).

A good test would be to use a `Hashtable` to store the indexes and lookup the indexes for each column in that `Hashtable` for each row. If performance is the same as calling `GetOrdinal` for each row, then you can safely assume that the overhead is in the `FieldNameLookup` calls.

Hope that helps.
You can [lookup the sourcecode for .NET framework objects to see what is happening under-the-hood](http://www.dotnetframework.org/default.aspx/FX-1434/FX-1434/1@0/untmp/whidbey/REDBITS/ndp/fx/src/Data/System/Data/DataTableReader@cs/1/DataTableReader@cs). From this example:

```
override public  Int32 GetOrdinal (string name) { 

            ValidateOpen("GetOrdinal");
            ValidateReader(); 
            DataColumn dc = currentDataTable.Columns[name];

            if (dc != null) {
                return dc.Ordinal;// WebData 113248 
            }
            else{ 
                throw ExceptionBuilder.ColumnNotInTheTable(name, currentDataTable.TableName); 
            }
        } 

```