Skip to content

Commit

Permalink
fix context argument bug when handlebars helpers is not block helper.…
Browse files Browse the repository at this point in the history
… rename old_ctx to _this
  • Loading branch information
Zordius Chen committed Feb 27, 2015
1 parent 0d3d1ef commit d1f1b93
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lightncandy.php
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ protected static function compileCustomHelper(&$context, &$vars, $raw, $err = fa
$ch = array_shift($vars);
$v = static::getVariableNames($vars, $context);
static::addUsageCount($context, $notHH ? 'helpers' : 'hbhelpers', $ch[0]);
return $context['ops']['seperator'] . static::getFuncName($context, $notHH ? 'ch' : 'hbch', "$ch[0] " . implode(' ', $v[1])) . "\$cx, '$ch[0]', {$v[0]}, '$fn'" . ($notHH ? '' : ', \'$in\'') . "){$context['ops']['seperator']}";
return $context['ops']['seperator'] . static::getFuncName($context, $notHH ? 'ch' : 'hbch', "$ch[0] " . implode(' ', $v[1])) . "\$cx, '$ch[0]', {$v[0]}, '$fn'" . ($notHH ? '' : ', $in') . "){$context['ops']['seperator']}";
}

/**
Expand Down Expand Up @@ -2515,7 +2515,7 @@ public static function hbch($cx, $ch, $vars, $op, $inverted, $cb = null, $else =
$options = array(
'name' => $ch,
'hash' => $vars[1],
'old_ctx' => $isBlock ? $op : end( $cx['scopes'] ),
'_this' => $isBlock ? $op : $inverted,
);

// $invert the logic
Expand Down

2 comments on commit d1f1b93

@werdnum
Copy link
Contributor

@werdnum werdnum commented on d1f1b93 Mar 3, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding this bug! I had no idea what was going on. Would it be possible to do a release so that I can require this feature in my composer.json?

@zordius
Copy link
Owner

@zordius zordius commented on d1f1b93 Mar 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v0.20 relased, thanks.

Please sign in to comment.