Permalink
Browse files

Partial's support added

  • Loading branch information...
1 parent 0891934 commit 3aa22796e94cc757477d3ce3cfd62906c3341d9c @GermanDZ GermanDZ committed Jan 26, 2012
Showing with 19 additions and 0 deletions.
  1. +4 −0 lib/handlebars.rb
  2. +15 −0 spec/handlebars_spec.rb
View
4 lib/handlebars.rb
@@ -15,6 +15,10 @@ def register_helper(name, &fn)
handlebars.registerHelper(name, fn)
end
+ def register_partial(name, str)
+ handlebars.registerPartial(name, str)
+ end
+
def handlebars
Handlebars.module_eval do
@loader.require('handlebars')
View
15 spec/handlebars_spec.rb
@@ -37,4 +37,19 @@
t.call.should eql "Hurray!Hurray!"
end
end
+
+ describe "registering Partials" do
+ Handlebars.register_partial('futher_info', 'futher information about {{name}}')
+ Handlebars.register_partial(:extra_info, 'more info')
+
+ it "render a simple content" do
+ t = compile("I have {{> extra_info}}")
+ t.call.should eql "I have more info"
+ end
+
+ it "render the content using data in context" do
+ t = compile("I also know {{> futher_info}}")
+ t.call(:name => "John").should eql "I also know futher information about John"
+ end
+ end
end

0 comments on commit 3aa2279

Please sign in to comment.