public
Fork of saturnflyer/radiant
Description: Radiant is a no-fluff, open source content management system designed for small teams.
Homepage: http://radiantcms.org/
Clone URL: git://github.com/MrGossett/radiant.git
added unless_ancestor_or_self and unless_self  with spec tests
MrGossett (author)
Wed Jul 23 06:12:33 -0700 2008
commit  cae8e0357b880b3d1db770637a3d16738e5153be
tree    0eef6aef17b72c7d6a8bb45c324eba679eac4032
parent  9e4c2c9fc65825a53ef055271bc378493450738d
...
389
390
391
 
 
 
 
 
 
 
 
 
 
 
 
392
393
394
...
401
402
403
 
 
 
 
 
 
 
 
 
 
 
 
404
405
406
...
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
...
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
0
@@ -389,6 +389,18 @@ module StandardTags
0
   end
0
   
0
   desc %{
0
+ Renders the contained elements unless the current contextual page is either the actual page or one of its parents.
0
+
0
+ This is typically used inside another tag (like <r:children:each>) to add conditional mark-up unless the child element is or descends from the current page.
0
+
0
+ *Usage:*
0
+ <pre><code><r:unless_ancestor_or_self>...</unless_ancestor_or_self></code></pre>
0
+ }
0
+ tag "unless_ancestor_or_self" do |tag|
0
+ tag.expand unless (tag.globals.page.ancestors + [tag.globals.page]).include?(tag.locals.page)
0
+ end
0
+
0
+ desc %{
0
     Renders the contained elements if the current contextual page is also the actual page.
0
     
0
     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.
0
@@ -401,6 +413,18 @@ module StandardTags
0
   end
0
   
0
   desc %{
0
+ Renders the contained elements unless the current contextual page is also the actual page.
0
+
0
+ This is typically used inside another tag (like &lt;r:children:each&gt;) to add conditional mark-up unless the child element is the current page.
0
+
0
+ *Usage:*
0
+ <pre><code><r:unless_self>...</unless_self></code></pre>
0
+ }
0
+ tag "unless_self" do |tag|
0
+ tag.expand unless tag.locals.page == tag.globals.page
0
+ end
0
+
0
+ desc %{
0
     Renders the name of the author of the current page.
0
   }
0
   tag 'author' do |tag|
...
766
767
768
 
 
 
 
 
 
 
 
 
 
769
770
771
...
776
777
778
 
 
 
 
 
 
 
 
 
 
779
780
781
...
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
...
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
0
@@ -766,6 +766,16 @@ describe "Standard Tags" do
0
       page(:parent).should render(%{<r:find url="/radius"><r:if_ancestor_or_self>true</r:if_ancestor_or_self></r:find>}).as('')
0
     end
0
   end
0
+
0
+ describe "<r:unless_ancestor_or_self>" do
0
+ it "should render the tag's content when the current page is not an ancestor of tag.locals.page" do
0
+ page(:radius).should render(%{<r:find url="/"><r:unless_ancestor_or_self>true</r:unless_ancestor_or_self></r:find>}).as('true')
0
+ end
0
+
0
+ it "should not render the tag's content when current page is an ancestor of tag.locals.page" do
0
+ page(:parent).should render(%{<r:find url="/radius"><r:unless_ancestor_or_self>true</r:unless_ancestor_or_self></r:find>}).as('')
0
+ end
0
+ end
0
 
0
   describe "<r:if_self>" do
0
     it "should render the tag's content when the current page is the same as the local contextual page" do
0
@@ -776,6 +786,16 @@ describe "Standard Tags" do
0
       page(:radius).should render(%{<r:find url="/"><r:if_self>true</r:if_self></r:find>}).as('')
0
     end
0
   end
0
+
0
+ describe "<r:unless_self>" do
0
+ it "should render the tag's content when the current page is not the same as the local contextual page" do
0
+ page(:home).should render(%{<r:find url="/"><r:unless_self>true</r:unless_self></r:find>}).as('true')
0
+ end
0
+
0
+ it "should not render the tag's content when the current page is the same as the local contextual page" do
0
+ page(:radius).should render(%{<r:find url="/"><r:unles_self>true</r:unless_self></r:find>}).as('')
0
+ end
0
+ end
0
 
0
   describe "<r:meta>" do
0
     it "should render <meta> tags for the description and keywords" do

Comments

    No one has commented yet.