Sha256: 60350df4d0e9fc377c9dc4468316e4a8efba759f95249e4f4417e3097709db8b
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 KB
Contents
require 'handlebars' describe(Handlebars::Context) do describe "a simple template" do let(:t) {subject.compile("Hello {{name}}")} it "allows simple subsitution" do t.call(:name => 'World').should eql "Hello World" end it "allows Ruby blocks as a property" do t.call(:name => lambda {|context| ;"Mate"}).should eql "Hello Mate" end it "can use any Ruby object as a context" do t.call(mock(:Object, :name => "Flipper")).should eql "Hello Flipper" end end describe "registering Helpers" do before do subject.register_helper('alsowith') do |this, context, block| block.call(context) end subject.register_helper(:twice) do |this, block| "#{block.call}#{block.call}" end end it "correctly passes context and implementation" do t = subject.compile("it's so {{#alsowith weather}}*{{summary}}*{{/alsowith}}!") t.call(:weather => {:summary => "sunny"}).should eql "it's so *sunny*!" end it "doesn't nee a context or arguments to the call" do t = subject.compile("{{#twice}}Hurray!{{/twice}}") t.call.should eql "Hurray!Hurray!" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
handlebars-0.2.2 | spec/handlebars_spec.rb |
handlebars-0.2.1 | spec/handlebars_spec.rb |
handlebars-0.2.0 | spec/handlebars_spec.rb |