Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Dialect#value_of and Dialect#evaluate are aliases.

  • Loading branch information...
commit 7f6c89ee886aa1d7c7afca426230cc430f95805c 1 parent 614a493
Bernard Lambeau authored
1  lib/wlang/dialect.rb
@@ -190,6 +190,7 @@ def evaluate(expr, *default)
190 190
         evaluate(render(expr), *default)
191 191
       end
192 192
     end
  193
+    alias :value_of :evaluate
193 194
 
194 195
   end # class Dialect
195 196
 end # module WLang
17  lib/wlang/html.rb
@@ -5,11 +5,6 @@ class Html < WLang::Dialect
5 5
 
6 6
     module Helpers
7 7
 
8  
-      def value_of(fn, *defaults)
9  
-        evaluate(render(fn).to_s.strip, *defaults)
10  
-      end
11  
-      private :value_of
12  
-
13 8
       def to_html(val)
14 9
         val = val.to_html if val.respond_to?(:to_html)
15 10
         val = to_html(val.call) if val.is_a?(Proc)
@@ -28,12 +23,12 @@ def escape_html(val)
28 23
     module HighOrderFunctions
29 24
 
30 25
       def bang(buf, fn)
31  
-        val = value_of(fn).to_s
  26
+        val = evaluate(fn).to_s
32 27
         render(val, nil, buf)
33 28
       end
34 29
 
35 30
       def plus(buf, fn)
36  
-        val = value_of(fn)
  31
+        val = evaluate(fn)
37 32
         val = to_html(val) unless val.is_a?(Template)
38 33
         render(val, nil, buf)
39 34
       end
@@ -56,7 +51,7 @@ def modulo(buf, fn)
56 51
       end
57 52
 
58 53
       def question(buf, fn_if, fn_then, fn_else)
59  
-        val   = value_of(fn_if)
  54
+        val   = evaluate(fn_if)
60 55
         val   = val.call if Proc===val
61 56
         block = val ? fn_then : fn_else
62 57
         render(block, nil, buf) if block
@@ -67,7 +62,7 @@ def caret(buf, fn_if, fn_then, fn_else)
67 62
       end
68 63
 
69 64
       def star(buf, coll_fn, elm_fn, between_fn)
70  
-        collection = value_of(coll_fn)
  65
+        collection = evaluate(coll_fn)
71 66
         collection.each_with_index do |elm,i|
72 67
           render(between_fn, elm, buf) if between_fn and (i > 0)
73 68
           render(elm_fn, elm, buf)
@@ -75,13 +70,13 @@ def star(buf, coll_fn, elm_fn, between_fn)
75 70
       end
76 71
 
77 72
       def greater(buf, fn)
78  
-        val = value_of(fn)
  73
+        val = evaluate(fn)
79 74
         val = Html.compile(val) if String === val
80 75
         render(val, nil, buf)
81 76
       end
82 77
 
83 78
       def sharp(buf, who_fn, then_fn)
84  
-        val = value_of(who_fn, nil)
  79
+        val = evaluate(who_fn, nil)
85 80
         if val and not(val.respond_to?(:empty?) and val.empty?)
86 81
           render(then_fn, val, buf)
87 82
         end

0 notes on commit 7f6c89e

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