Permalink
Browse files

Fix Html's >{yield}.

  • Loading branch information...
1 parent b68aad4 commit 5ee52f44b60afb0042ab20f726b5508c289ddfd0 @blambeau committed Jun 13, 2012
Showing with 9 additions and 1 deletion.
  1. +3 −0 CHANGELOG.md
  2. +1 −0 lib/wlang/html.rb
  3. +5 −1 spec/integration/html/test_greater.rb
View
@@ -17,6 +17,9 @@
* Dialect#evaluate (through Scope#evaluate) now accepts an optional block for specifying
a computed default value instead of failing.
+* WLang::Html partial tag >{...} now recognizes a Proc and simply renders the result of
+ calling it. This allows to use >{yield} in layouts instead of the less idomatic +{yield}.
+
# 2.0.1 / 2012-06-12
* Fix support for 1.8.7 and jruby (undefined method `ord' for String)
View
@@ -72,6 +72,7 @@ def star(buf, coll_fn, elm_fn, between_fn)
def greater(buf, fn)
val = evaluate(fn)
val = Html.compile(val) if String === val
+ val = val.call if Proc === val
render(val, nil, buf)
end
@@ -1,5 +1,4 @@
require 'spec_helper'
-require 'wlang/html'
module WLang
describe Html, ">{...}" do
@@ -25,5 +24,10 @@ def render(tpl, scope = {})
render("Hello >{partial}", binding).should eq("Hello World")
end
+ it 'call a Proc as +{...} does' do
+ partial = Proc.new{ "World" }
+ render("Hello >{partial}", binding).should eq("Hello World")
+ end
+
end
end

0 comments on commit 5ee52f4

Please sign in to comment.