mirror of
https://github.com/Mibew/handlebars.php.git
synced 2025-04-15 10:57:24 +03:00
Make the fix for #105 more elegant, using $template->parseArguments()
This commit is contained in:
parent
2b3d450849
commit
84b3031a44
@ -50,15 +50,8 @@ class IfHelper implements Helper
|
||||
*/
|
||||
public function execute(Template $template, Context $context, $args, $source)
|
||||
{
|
||||
if (is_numeric($args)) {
|
||||
$tmp = $args;
|
||||
} elseif(preg_match('/^\'.*\'$/', trim($args))) {
|
||||
$tmp = preg_replace('/^\'(.*)\'$/', '$1', trim($args));
|
||||
} elseif(preg_match('/^".*"$/', trim($args))) {
|
||||
$tmp = preg_replace('/^"(.*)"$/', '$1', trim($args));
|
||||
} else {
|
||||
$tmp = $context->get($args);
|
||||
}
|
||||
$parsedArgs = $template->parseArguments($args);
|
||||
$tmp = $context->get($parsedArgs[0]);
|
||||
|
||||
$context->push($context->last());
|
||||
if ($tmp) {
|
||||
|
@ -50,15 +50,8 @@ class UnlessHelper implements Helper
|
||||
*/
|
||||
public function execute(Template $template, Context $context, $args, $source)
|
||||
{
|
||||
if (is_numeric($args)) {
|
||||
$tmp = $args;
|
||||
} elseif(preg_match('/^\'.*\'$/', trim($args))) {
|
||||
$tmp = preg_replace('/^\'(.*)\'$/', '$1', trim($args));
|
||||
} elseif(preg_match('/^".*"$/', trim($args))) {
|
||||
$tmp = preg_replace('/^"(.*)"$/', '$1', trim($args));
|
||||
} else {
|
||||
$tmp = $context->get($args);
|
||||
}
|
||||
$parsedArgs = $template->parseArguments($args);
|
||||
$tmp = $context->get($parsedArgs[0]);
|
||||
|
||||
$context->push($context->last());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user