I have the following code in a .haml template file in a Sinatra app:
- if(@order == 'inverse')
- @list.reverse_each do |item|
.item
%span.action-move(data-icon="o")
.detail.title=item[0]
.detail.content=item[1]
%span.action-delete(data-icon="d")
- else
- @list.each do |item|
.item
%span.action-move(data-icon="o")
.detail.title=item[0]
.detail.content=item[1]
%span.action-delete(data-icon="d")
As you can see, 5 lines of code are identical. Is there a way that I can refactor this code to avoid the duplication here without creating an additional file to use as a partial?