.all method for content_type drop to evaluate collection inside of scope (fixes #74)
Ivan Youroff
committed Jun 28, 2013
commit fc129fc3ed10caa1d7d3b72a6431d080fabd9898
Showing 3
changed files with
22 additions
and 0 deletions
locomotive/wagon/liquid/drops/content_types.rb b/lib/locomotive/wagon/liquid/drops/content_types.rb
+4
-0
| @@ | @@ -21,6 +21,10 @@ module Locomotive |
| @collection = nil | |
| end | |
| + | def all |
| + | self.collection |
| + | end |
| + | |
| def first | |
| self.collection.first | |
| end | |
spec/fixtures/default/app/views/pages/music.liquid.haml
+8
-0
| @@ | @@ -25,4 +25,12 @@ position: 2 |
| {% include 'song' with song %} | |
| {% endfor %} | |
| #is_listed{listed: "{{ page.listed? }}"} | |
| + | #test_for_scope |
| + | {% with_scope _slug: "song-3" %} |
| + | {% assign selected_songs = contents.songs.all %} |
| + | {% endwith_scope %} |
| + | {% for s in selected_songs %} |
| + | %p.scoped_song {{ s._label }} |
| + | {% endfor %} |
| + | %p.collection_equality {{ contents.songs.all.size }}={{ contents.songs.size }} |
| {% endblock %} | |
| \ No newline at end of file | |
spec/integration/server/liquid_spec.rb
+10
-0
| @@ | @@ -36,4 +36,14 @@ describe Locomotive::Wagon::Server do |
| get '/songs/song-1' | |
| last_response.body.should =~ /content_type_count=.8./ | |
| end | |
| + | |
| + | it "evaluates collection when called all inside of scope" do |
| + | get '/music' |
| + | last_response.body.should =~ /<p class=.scoped_song.>Song #3/ |
| + | end |
| + | |
| + | it "size of evaluated unscoped collection eqaul to unevaluated one" do |
| + | get '/music' |
| + | last_response.body.should =~ /class=.collection_equality.>8=8/ |
| + | end |
| end | |
| \ No newline at end of file | |