Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix Html's >{yield}.
  • Loading branch information
blambeau committed Jun 13, 2012
1 parent b68aad4 commit 5ee52f4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/wlang/html.rb
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion spec/integration/html/test_greater.rb
@@ -1,5 +1,4 @@
require 'spec_helper'
require 'wlang/html'
module WLang
describe Html, ">{...}" do

Expand All @@ -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.