summaryrefslogtreecommitdiffstats
path: root/spec/parser_spec.rb
diff options
context:
space:
mode:
authortomhuda <tomhuda@strobecorp.com>2011-03-04 00:11:03 -0800
committertomhuda <tomhuda@strobecorp.com>2011-03-04 00:11:03 -0800
commitca9b9671a54f81e3b942118c7b0277029b816787 (patch)
treeda4438a3efa9beeee3b195c73600622ce6f2b922 /spec/parser_spec.rb
parente0aa705f71ec745f1444c6a05aa9b49a408b8435 (diff)
downloadhandlebars.js-ca9b9671a54f81e3b942118c7b0277029b816787.zip
handlebars.js-ca9b9671a54f81e3b942118c7b0277029b816787.tar.gz
handlebars.js-ca9b9671a54f81e3b942118c7b0277029b816787.tar.bz2
Add Hash arguments to simple mustaches (TODO: add Hash args to block helpers)
Diffstat (limited to 'spec/parser_spec.rb')
-rw-r--r--spec/parser_spec.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb
index edcc665..3c6250a 100644
--- a/spec/parser_spec.rb
+++ b/spec/parser_spec.rb
@@ -65,8 +65,9 @@ describe "Parser" do
with_padding { yield }
end
- def mustache(id, *params)
- pad("{{ #{id} [#{params.join(", ")}] }}")
+ def mustache(id, params = [], hash = nil)
+ hash = " #{hash}" if hash
+ pad("{{ #{id} [#{params.join(", ")}]#{hash} }}")
end
def partial(id, context = nil)
@@ -113,29 +114,29 @@ describe "Parser" do
end
it "parses mustaches with parameters" do
- ast_for("{{foo bar}}").should == program { mustache id("foo"), id("bar") }
+ ast_for("{{foo bar}}").should == program { mustache id("foo"), [id("bar")] }
end
it "parses mustaches with hash arguments" do
ast_for("{{foo bar=baz}}").should == program do
- mustache id("foo"), hash(["bar", "ID:baz"])
+ mustache id("foo"), [], hash(["bar", "ID:baz"])
end
ast_for("{{foo bar=baz bat=bam}}").should == program do
- mustache id("foo"), hash(["bar", "ID:baz"], ["bat", "ID:bam"])
+ mustache id("foo"), [], hash(["bar", "ID:baz"], ["bat", "ID:bam"])
end
ast_for("{{foo bar=baz bat=\"bam\"}}").should == program do
- mustache id("foo"), hash(["bar", "ID:baz"], ["bat", "\"bam\""])
+ mustache id("foo"), [], hash(["bar", "ID:baz"], ["bat", "\"bam\""])
end
ast_for("{{foo omg bar=baz bat=\"bam\"}}").should == program do
- mustache id("foo"), id("omg"), hash(["bar", id("baz")], ["bat", string("bam")])
+ mustache id("foo"), [id("omg")], hash(["bar", id("baz")], ["bat", string("bam")])
end
end
it "parses mustaches with string parameters" do
- ast_for("{{foo bar \"baz\" }}").should == program { mustache id("foo"), id("bar"), string("baz")}
+ ast_for("{{foo bar \"baz\" }}").should == program { mustache id("foo"), [id("bar"), string("baz")] }
end
it "parses contents followed by a mustache" do