Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Pass an instance of \Handlebars\Arguments to a helper #90

Open
JustBlackBird opened this issue Sep 17, 2014 · 4 comments
Open

Pass an instance of \Handlebars\Arguments to a helper #90

JustBlackBird opened this issue Sep 17, 2014 · 4 comments
Milestone

Comments

@JustBlackBird
Copy link
Contributor

It will be more convenient if a helper receives an instance of \Handlebars\Arguments instead of arguments string. In this case a helper should know nothing about parsing and just uses already prepared arguments. Also if we parse an arguments string before calling a helper we can guarantee that arguments string is valid.

I could provide a pull request, if the maintainers are interesting in it.

@fzerorubigd
Copy link
Contributor

Its a good idea. But what about BC break? How we can maintain backward compatibility? And if we can not, I think its time to migrate to another branch (develop for example)

@JustBlackBird
Copy link
Contributor Author

\Handlebars\Arguments has magic __toString method. Thus it can be freely used in string context. The only problem is is_numeric function that used directly on arguments string in several places.

@fzerorubigd
Copy link
Contributor

Can you point the exact location of problems? maybe we can fix them.

@JustBlackBird
Copy link
Contributor Author

is_numeric is a compatibility problem for custom helpers. Here is an example:

$args = '92'; // just string
is_numeric($args); // returns true

// The same argument string but wrapped with the class
$args = new \Handlebars\Arguments('92');
is_numeric($args); // returns false

@fzerorubigd fzerorubigd added this to the v0.11.0 milestone Dec 12, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants