require 'musterb/template_handler'
describe Musterb::TemplateHandler do
def evaluate(template, binding)
compiled = "output_buffer = nil; " + Musterb::TemplateHandler::compile_mustache(template)
binding.eval compiled
end
it "is wired up correctly" do
foo = "hi"
evaluate("{{foo}}", binding).should eq "hi"
end
it "renders partials corrects" do
Musterb::TemplateHandler::compile_mustache("{{>foo}}").should include "render :partial => 'foo', :locals => {:initial_context => musterb.context}"
end
it "escapes things by default" do
foo = "
"
evaluate("{{foo}}", binding).should eq "<br>"
end
it "does not escape things in triple staches" do
foo = "
"
evaluate("{{{foo}}}", binding).should eq "
"
end
end