XaminProject / handlebars.php

Handlebars processor for php
331 stars 134 forks source link

Refactor of Quoted Literal String Handling and More tests #37

Closed cgray closed 10 years ago

cgray commented 10 years ago

This PR fixes the internal representation of a Quoted String Literal from a strangely quoted string to an instance of \Handlebars\String.

This should move the some of the complexity I previously added to the \Handlbars\Context::get method into \Handlebars\Template::parseArguments

Template::parseAruments on

{{#ifEquals var "Some Value"}}

Previously would have resulted in

["var", '"Some Value"']

And Context::get treated it as a string literal based on the string staring and ending with a quote.

Now parseArguments results in

["var", new \Handlebars\String("Some Value")]

and Context::get treats instances of Handlebars\String as string literals.

Also added a couple of new test cases to test the previously uncovered Template::parseArguments and added to existing test cases.

everplays commented 10 years ago

Thanks @cgray, I like the way that the result of parseArguments can be mapped by Context::get to get exactly what arguments mean.