diff --git a/src/Handlebars/Helper.php b/src/Handlebars/Helper.php index 6c5c121..725099d 100644 --- a/src/Handlebars/Helper.php +++ b/src/Handlebars/Helper.php @@ -31,10 +31,10 @@ interface Helper /** * Execute the helper * - * @param \Handlebars\Template $template The template instance - * @param \Handlebars\Context $context The current context - * @param array $args The arguments passed the the helper - * @param string $source The source + * @param \Handlebars\Template $template The template instance + * @param \Handlebars\Context $context The current context + * @param \Handlebars\Arguments $args The arguments passed the the helper + * @param string $source The source * * @return mixed */ diff --git a/src/Handlebars/Helper/BindAttrHelper.php b/src/Handlebars/Helper/BindAttrHelper.php index f3c4f0e..a301c4a 100644 --- a/src/Handlebars/Helper/BindAttrHelper.php +++ b/src/Handlebars/Helper/BindAttrHelper.php @@ -41,10 +41,10 @@ class BindAttrHelper implements Helper /** * Execute the helper * - * @param \Handlebars\Template $template The template instance - * @param \Handlebars\Context $context The current context - * @param array $args The arguments passed the the helper - * @param string $source The source + * @param \Handlebars\Template $template The template instance + * @param \Handlebars\Context $context The current context + * @param \Handlebars\Arguments $args The arguments passed the the helper + * @param string $source The source * * @return mixed */ diff --git a/src/Handlebars/Helper/EachHelper.php b/src/Handlebars/Helper/EachHelper.php index d2dc49c..fb871c9 100644 --- a/src/Handlebars/Helper/EachHelper.php +++ b/src/Handlebars/Helper/EachHelper.php @@ -43,16 +43,17 @@ class EachHelper implements Helper /** * Execute the helper * - * @param \Handlebars\Template $template The template instance - * @param \Handlebars\Context $context The current context - * @param array $args The arguments passed the the helper - * @param string $source The source + * @param \Handlebars\Template $template The template instance + * @param \Handlebars\Context $context The current context + * @param \Handlebars\Arguments $args The arguments passed the the helper + * @param string $source The source * * @return mixed */ public function execute(Template $template, Context $context, $args, $source) { - $tmp = $context->get($args); + $positionalArgs = $args->getPositionalArguments(); + $tmp = $context->get($positionalArgs[0]); $buffer = ''; if (!$tmp) { diff --git a/src/Handlebars/Helper/IfHelper.php b/src/Handlebars/Helper/IfHelper.php index e4dd945..54d4952 100644 --- a/src/Handlebars/Helper/IfHelper.php +++ b/src/Handlebars/Helper/IfHelper.php @@ -41,20 +41,17 @@ class IfHelper implements Helper /** * Execute the helper * - * @param \Handlebars\Template $template The template instance - * @param \Handlebars\Context $context The current context - * @param array $args The arguments passed the the helper - * @param string $source The source + * @param \Handlebars\Template $template The template instance + * @param \Handlebars\Context $context The current context + * @param \Handlebars\Arguments $args The arguments passed the the helper + * @param string $source The source * * @return mixed */ public function execute(Template $template, Context $context, $args, $source) { - if (is_numeric($args)) { - $tmp = $args; - } else { - $tmp = $context->get($args); - } + $postionalArgs = $args->getPositionalArguments(); + $tmp = $context->get($postionalArgs[0]); $context->push($context->last()); if ($tmp) { diff --git a/src/Handlebars/Helper/UnlessHelper.php b/src/Handlebars/Helper/UnlessHelper.php index f851bf7..fcdfdac 100644 --- a/src/Handlebars/Helper/UnlessHelper.php +++ b/src/Handlebars/Helper/UnlessHelper.php @@ -41,16 +41,17 @@ class UnlessHelper implements Helper /** * Execute the helper * - * @param \Handlebars\Template $template The template instance - * @param \Handlebars\Context $context The current context - * @param array $args The arguments passed the the helper - * @param string $source The source + * @param \Handlebars\Template $template The template instance + * @param \Handlebars\Context $context The current context + * @param \Handlebars\Arguments $args The arguments passed the the helper + * @param string $source The source * * @return mixed */ public function execute(Template $template, Context $context, $args, $source) { - $tmp = $context->get($args); + $positionalArgs = $args->getPositionalArguments(); + $tmp = $context->get($positionalArgs[0]); $context->push($context->last()); diff --git a/src/Handlebars/Helper/WithHelper.php b/src/Handlebars/Helper/WithHelper.php index 262c6dd..647c9dd 100644 --- a/src/Handlebars/Helper/WithHelper.php +++ b/src/Handlebars/Helper/WithHelper.php @@ -41,16 +41,17 @@ class WithHelper implements Helper /** * Execute the helper * - * @param \Handlebars\Template $template The template instance - * @param \Handlebars\Context $context The current context - * @param array $args The arguments passed the the helper - * @param string $source The source + * @param \Handlebars\Template $template The template instance + * @param \Handlebars\Context $context The current context + * @param \Handlebars\Arguments $args The arguments passed the the helper + * @param string $source The source * * @return mixed */ public function execute(Template $template, Context $context, $args, $source) { - $context->with($args); + $positionalArgs = $args->getPositionalArguments(); + $context->with($positionalArgs[0]); $buffer = $template->render($context); $context->pop(); diff --git a/src/Handlebars/Helpers.php b/src/Handlebars/Helpers.php index 216bcb7..beaad8b 100644 --- a/src/Handlebars/Helpers.php +++ b/src/Handlebars/Helpers.php @@ -124,13 +124,14 @@ public function call($name, Template $template, Context $context, $args, $source throw new \InvalidArgumentException('Unknown helper: ' . $name); } + $parsedArgs = new Arguments($args); if ($this->helpers[$name] instanceof Helper) { return $this->helpers[$name]->execute( - $template, $context, $args, $source + $template, $context, $parsedArgs, $source ); } - return call_user_func($this->helpers[$name], $template, $context, $args, $source); + return call_user_func($this->helpers[$name], $template, $context, $parsedArgs, $source); } /**