Skip to content

Instantly share code, notes, and snippets.

@tomas-stefano
Created December 22, 2010 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tomas-stefano/751491 to your computer and use it in GitHub Desktop.
Save tomas-stefano/751491 to your computer and use it in GitHub Desktop.
Attempt to Reproduce the bug
####### ONLY DataMapper #######
>> episodes = Episode.all
[#<Episode @id=1 @title="Cache Variable">, #<Episode @id=2 @title="Cache Variable"> , #<Episode @id=3 @title="Cache Variable">]
>> episode = episodes.shift
>> episodes.each do |e|
>> puts e.id
>> end
1
2
3
### HAML AND DATAMAPPER ######
### Assuming that @episodes is:
#
# [#<Episode @id=1 @title="Cache Variable">, #<Episode @id=2 @title="Cache Variable"> , #<Episode @id=3 @title="Cache Variable">]
#
#current_episode
- unless @episodes.empty?
- @episode = @episodes.shift
%h3
= "Episódio #{@episode.id} - #{@episode.title}"
%span
= @episode.description
#other_episodes
- @episodes.each do |episode|
%h3
= "Episódio #{episode.id} - #{episode.title}"
%span
= episode.description
#### The OUTPUT ####
<div id="current_episode">
<h3>Episódio 1 - Cache Variable</h3>
</div>
<div id="other-episodes">
<h3>Episódio 2 - Cache Variable</h3>
<span>...</span>
<!-- WTF???????? -->
<h3>Episódio 2 - Cache Variable</h3>
<span>...</span>
<!-- WTF???????? -->
<h3>Episódio 3 - Cache Variable</h3>
<span>...</span>
</div>
### HAML AND DATAMAPPER ######
### Assuming that @episodes is:
#
# [#<Episode @id=1 @title="Cache Variable">, #<Episode @id=2 @title="Cache Variable"> , #<Episode @id=3 @title="Cache Variable">]
#
#current_episode
- unless @episodes.empty?
- @episode = @episodes.shift
%h3
= "Episódio #{@episode.id} - #{@episode.title}"
%span
= @episode.description
- # INSTEAD ITERATE over a DataMapper collection, just converto to a Ruby Array and it works very well
- #
- # So Appears this is a bug in the Haml
-
#other_episodes
- @episodes.to_a.each do |episode|
%h3
= "Episódio #{episode.id} - #{episode.title}"
%span
= episode.description
#### The OUTPUT ####
<div id="current_episode">
<h3>Episódio 1 - Cache Variable</h3>
</div>
<div id="other-episodes">
<h3>Episódio 2 - Cache Variable</h3>
<span>...</span>
<h3>Episódio 3 - Cache Variable</h3>
<span>...</span>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment