Awesome, always had this thought too! Attached patch for <r:unless>, a decent substitute for an else tag



Index: back_door_tags.rb
===================================================================
--- back_door_tags.rb   (revision 2)
+++ back_door_tags.rb   (working copy)
@@ -67,4 +67,15 @@
     tag.expand if eval( tag.attr[ "cond"])
   end

+  desc %{
+ Renders the tag body if the given Ruby expression evaluates to false. Pair with an <r:if> for if/else
+
+    *Usage:*
+ <pre><code> <r:unless cond="[ruby expression]"> [HTML content] </ r:unless> </code></pre>
+  }
+  tag "unless" do |tag|
+ raise TagError.new( "'unless' tag must contain a 'cond' attribute.") unless tag.attr.has_key?( "cond")
+    tag.expand unless eval( tag.attr[ "cond"])
+  end
+
 end







---
Jamie Wilkinson _____________<http://www.tramchase.com/blog>
mailto:[EMAIL PROTECTED] ________ aim:jwilksdub


On Aug 23, 2007, at 11:51 AM, Aitor Garay-Romero wrote:

Hi!

I had this idea in my head for a long time and finally implemented it.

More info in the project home page: http:// backdoor.rubyforge.org/ .
Comments, etc welcomed.

    /AITOR
_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to