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.
Haml
%ul
= list_of [1, 2, 3] do |item|
Number #{item}
HTML
<ul>
<li>Number 1</li>
<li>Number 2</li>
<li>Number 3</li>
</ul>
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.