Changeset 814

Show
Ignore:
Timestamp:
04/18/08 15:47:34 (5 months ago)
Author:
seancribbs
Message:

Merge branch 'master' of git://github.com/mghaught/radiant

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/radiant/app/models/standard_tags.rb

    r806 r814  
    332332        tag.expand 
    333333    end 
     334  end 
     335 
     336  desc %{ 
     337    Renders the contained elements if the current contextual page is either the actual page or one of its parents. 
     338 
     339                This is typically used inside another tag (like <r:children:each>) to add conditional mark-up if the child element is or descends from the current page. 
     340                     
     341    *Usage:* 
     342    <pre><code><r:if_ancestor_or_self>...</if_ancestor_or_self></code></pre> 
     343  }   
     344        tag "if_ancestor_or_self" do |tag| 
     345                tag.expand if (tag.globals.actual_page.ancestors + [tag.globals.actual_page]).include?(tag.locals.page) 
     346        end 
     347         
     348  desc %{ 
     349    Renders the contained elements if the current contextual page is also the actual page. 
     350 
     351                This is typically used inside another tag (like &lt;r:children:each&gt;) to add conditional mark-up if the child element is the current page. 
     352                 
     353                *Usage:* 
     354    <pre><code><r:if_self>...</if_self></code></pre> 
     355  } 
     356  tag "if_self" do |tag| 
     357    tag.expand if tag.locals.page == tag.globals.actual_page 
    334358  end 
    335359   
  • trunk/radiant/spec/models/standard_tags_spec.rb

    r806 r814  
    464464  end 
    465465   
     466        describe "<r:if_ancestor_or_self>" do 
     467          it "should render the tag's content when the current page is an ancestor of tag.locals.page" do 
     468        page(:home).should render(%{<r:find url="/radius"><r:if_ancestor_or_self>true</r:if_ancestor_or_self></r:find>}).as('true') 
     469          end      
     470         
     471                it "should not render the tag's content when current page is not an ancestor of tag.locals.page" do 
     472            page(:parent).should render(%{<r:find url="/radius"><r:if_ancestor_or_self>true</r:if_ancestor_or_self></r:find>}).as('') 
     473          end 
     474        end 
     475 
    466476  private 
    467477