« Disruptive Innovation Within the Enterprise? | Main | Robert Williams, man to watch in 2014 »

November 20, 2013

Haml's little-known list_of helper

TIL that given an Enumerable object and a block, the list_of method will iterate and yield the results of the block into sequential <li> elements.


  = list_of [1, 2, 3] do |item|
    Number #{item}


  <li>Number 1</li>
  <li>Number 2</li>
  <li>Number 3</li>

The list_of method also optionally takes a hash of options applied to the output li tags as attributes.

Interested in more information like this? You can download my book The Rails 4 Way at Leanpub today. Final print edition on Addison Wesley coming early next year.

If you read this far you should probably follow me on twitter:


TrackBack URL for this entry:

Listed below are links to weblogs that reference Haml's little-known list_of helper:

Sponsored By


or visit my my homepage

My Companies

My Latest Books

My Book Series