diff --git a/lib/locomotive/liquid/drops/page.rb b/lib/locomotive/liquid/drops/page.rb index 263d032d..63a0c85f 100644 --- a/lib/locomotive/liquid/drops/page.rb +++ b/lib/locomotive/liquid/drops/page.rb @@ -16,6 +16,10 @@ module Locomotive def parent @parent ||= self._source.parent.to_liquid end + + def breadcrumbs + @breadcrumbs ||= liquify(*self._source.self_and_ancestors) + end def children @children ||= liquify(*self._source.children) diff --git a/spec/lib/locomotive/liquid/drops/page_spec.rb b/spec/lib/locomotive/liquid/drops/page_spec.rb index 7af1b32d..303bc198 100644 --- a/spec/lib/locomotive/liquid/drops/page_spec.rb +++ b/spec/lib/locomotive/liquid/drops/page_spec.rb @@ -52,6 +52,17 @@ describe Locomotive::Liquid::Drops::Page do end end + + context '#breadcrumbs' do + before(:each) do + @sub_page = Factory.build(:sub_page, :meta_keywords => 'Sub Libidinous, Angsty', :meta_description => "Sub Quite the combination.") + end + + it 'renders breadcrumbs of current page' do + content = render_template '{% for crumb in sub_page.breadcrumbs %}{{ crumb.title}},{% endfor %}', {'sub_page' => @sub_page} + content.should == 'Home page,Subpage,' + end + end context '#rendering page title' do