Merge pull request #66 from jslegers/master

Fix for detecting assocc arrays with one item as list
This commit is contained in:
Behrooz Shabani 2014-07-02 22:52:27 +04:30
commit bc56af2e83

View File

@ -10,6 +10,7 @@
* @author Behrooz Shabani <everplays@gmail.com>
* @author Dmitriy Simushev <simushevds@gmail.com>
* @author Jeff Turcotte <jeff.turcotte@gmail.com>
* @author John Slegers <slegersjohn@gmail.com>
* @copyright 2014 Authors
* @license MIT <http://opensource.org/licenses/MIT>
* @version GIT: $Id$
@ -31,6 +32,7 @@ use Handlebars\Template;
* @author Behrooz Shabani <everplays@gmail.com>
* @author Dmitriy Simushev <simushevds@gmail.com>
* @author Jeff Turcotte <jeff.turcotte@gmail.com>
* @author John Slegers <slegersjohn@gmail.com>
* @copyright 2014 Authors
* @license MIT <http://opensource.org/licenses/MIT>
* @version Release: @package_version@
@ -59,7 +61,7 @@ class EachHelper implements Helper
$template->setStopToken(false);
$buffer = $template->render($context);
} elseif (is_array($tmp) || $tmp instanceof \Traversable) {
$isList = is_array($tmp) && (array_keys($tmp) == range(0, count($tmp) - 1));
$isList = is_array($tmp) && (array_keys($tmp) === range(0, count($tmp) - 1));
$index = 0;
$lastIndex = $isList ? (count($tmp) - 1) : false;