Permalink
Browse files

Dialect#value_of and Dialect#evaluate are aliases.

  • Loading branch information...
1 parent 614a493 commit 7f6c89ee886aa1d7c7afca426230cc430f95805c @blambeau committed Jun 13, 2012
Showing with 7 additions and 11 deletions.
  1. +1 −0 lib/wlang/dialect.rb
  2. +6 −11 lib/wlang/html.rb
View
@@ -190,6 +190,7 @@ def evaluate(expr, *default)
evaluate(render(expr), *default)
end
end
+ alias :value_of :evaluate
end # class Dialect
end # module WLang
View
@@ -5,11 +5,6 @@ class Html < WLang::Dialect
module Helpers
- def value_of(fn, *defaults)
- evaluate(render(fn).to_s.strip, *defaults)
- end
- private :value_of
-
def to_html(val)
val = val.to_html if val.respond_to?(:to_html)
val = to_html(val.call) if val.is_a?(Proc)
@@ -28,12 +23,12 @@ def escape_html(val)
module HighOrderFunctions
def bang(buf, fn)
- val = value_of(fn).to_s
+ val = evaluate(fn).to_s
render(val, nil, buf)
end
def plus(buf, fn)
- val = value_of(fn)
+ val = evaluate(fn)
val = to_html(val) unless val.is_a?(Template)
render(val, nil, buf)
end
@@ -56,7 +51,7 @@ def modulo(buf, fn)
end
def question(buf, fn_if, fn_then, fn_else)
- val = value_of(fn_if)
+ val = evaluate(fn_if)
val = val.call if Proc===val
block = val ? fn_then : fn_else
render(block, nil, buf) if block
@@ -67,21 +62,21 @@ def caret(buf, fn_if, fn_then, fn_else)
end
def star(buf, coll_fn, elm_fn, between_fn)
- collection = value_of(coll_fn)
+ collection = evaluate(coll_fn)
collection.each_with_index do |elm,i|
render(between_fn, elm, buf) if between_fn and (i > 0)
render(elm_fn, elm, buf)
end
end
def greater(buf, fn)
- val = value_of(fn)
+ val = evaluate(fn)
val = Html.compile(val) if String === val
render(val, nil, buf)
end
def sharp(buf, who_fn, then_fn)
- val = value_of(who_fn, nil)
+ val = evaluate(who_fn, nil)
if val and not(val.respond_to?(:empty?) and val.empty?)
render(then_fn, val, buf)
end

0 comments on commit 7f6c89e

Please sign in to comment.