Skip to content
This repository
Browse code

Merge radius updates from trans/master

  • Loading branch information...
commit b8e105ba19f6741670e5725d63b3ca6a9d9b92bb 2 parents 4bdc4a8 + c43c8d1
Ryan Tomayko authored May 13, 2010
2  README.md
Source Rendered
@@ -33,6 +33,8 @@ Support for these template engines is included with the package:
33 33
     Mustache                   .mustache         mustache
34 34
     RDiscount                  .markdown         rdiscount
35 35
     RedCloth                   .textile          redcloth
  36
+    RDoc                       .rdoc             rdoc
  37
+    Radius                     .radius           radius
36 38
 
37 39
 See [TEMPLATES.md][t] for detailed information on template engine
38 40
 options and supported features.
53  TEMPLATES.md
Source Rendered
@@ -432,3 +432,56 @@ engine in a threaded environment.
432 432
 ### See also
433 433
 
434 434
  * [RDoc](http://rdoc.sourceforge.net/doc/index.html)
  435
+
  436
+
  437
+<a name='radius'></a>
  438
+Radius (`radius`)
  439
+-----------------
  440
+
  441
+Radius is the template language used by Radiant CMS. It is a tag
  442
+language designed to be valid XML/HTML.
  443
+
  444
+### Example
  445
+
  446
+    <html>
  447
+    <body>
  448
+      <h1><r:title /></h1>
  449
+      <ul class="<r:type />">
  450
+      <r:repeat times="3">
  451
+        <li><r:hello />!</li>
  452
+      </r:repeat>
  453
+      </ul>
  454
+      <r:yield />
  455
+   </body>
  456
+   </html>
  457
+
  458
+### Usage
  459
+
  460
+To render a template such as the one above.
  461
+
  462
+    scope = OpenStruct.new
  463
+    scope.title = "Radius Example"
  464
+    scope.hello = "Hello, World!"
  465
+
  466
+    require 'radius'
  467
+    template = Tilt::RadiusTemplate.new('example.radius', :tag_prefix=>'r')
  468
+    template.render(scope, :type=>'hlist'){ "Jackpot! }
  469
+
  470
+The result will be:
  471
+
  472
+    <html>
  473
+    <body>
  474
+      <h1>Radius Example</h1>
  475
+      <ul class="hlist">
  476
+        <li>Hello, World!</li>
  477
+        <li>Hello, World!</li>
  478
+        <li>Hello, World!</li>
  479
+      </ul>
  480
+      Jackpot!
  481
+   </body>
  482
+   </html>
  483
+
  484
+### See also
  485
+
  486
+* [Radius](http://radius.rubyforge.org/)
  487
+* [Radiant](http://radiantcms.org/)
11  lib/tilt.rb
@@ -753,6 +753,7 @@ def evaluate(scope, locals, &block)
753 753
   end
754 754
   register 'coffee', CoffeeTemplate
755 755
 
  756
+
756 757
   # Radius Template
757 758
   # http://github.com/jlong/radius/
758 759
   class RadiusTemplate < Template
@@ -774,12 +775,16 @@ def evaluate(scope, locals, &block)
774 775
           if locals.key?(tag.to_sym)
775 776
             locals[tag.to_sym]
776 777
           else
777  
-            scope.__send__(tag)  # any way to support attr as args?
  778
+            if scope.respond_to?(:__tilt__) # FIXME: is this right?
  779
+              scope.__send__(tag)  # any way to support attr as args?
  780
+            else
  781
+              scope.instance_eval(tag)
  782
+            end
778 783
           end
779 784
         end
780 785
       end
781  
-      # TODO: how to config tag prefix?
782  
-      parser = Radius::Parser.new(@context, :tag_prefix => 'r')
  786
+      options = {:tag_prefix => 'r'}.merge(@options)
  787
+      parser = Radius::Parser.new(@context, options)
783 788
       parser.parse(data)
784 789
     end
785 790
   end
10  test/tilt_radiustemplate_test.rb
@@ -41,6 +41,16 @@ def whisky; 'wetter'; end
41 41
         template.render(scope, :beer => 'great', :whisky => 'greater')
42 42
     end
43 43
 
  44
+    #test "handles local scope" do
  45
+    #  beer   = 'wet'
  46
+    #  whisky = 'wetter'
  47
+    #
  48
+    #  template = Tilt::RadiusTemplate.new {
  49
+    #    'Beer is <r:beer /> but Whisky is <r:whisky />.'
  50
+    #  }
  51
+    #  assert_equal "Beer is wet but Whisky is wetter.", template.render(self)
  52
+    #end
  53
+
44 54
     test "passing a block for yield" do
45 55
       template = Tilt::RadiusTemplate.new {
46 56
         'Beer is <r:yield /> but Whisky is <r:yield />ter.'

0 notes on commit b8e105b

Please sign in to comment.
Something went wrong with that request. Please try again.