Merge branch 'dev' into feature/pragma-dot-notation

Conflicts:
	README.markdown
This commit is contained in:
Justin Hileman
2010-04-26 22:03:03 -04:00
9 changed files with 46 additions and 12 deletions
+17 -2
View File
@@ -142,12 +142,16 @@ class Mustache {
// regular section
case '#':
if (is_array($val)) {
if ($this->varIsIterable($val)) {
foreach ($val as $local_context) {
$replace .= $this->_render($content, $this->getContext($context, $local_context));
}
} else if ($val) {
$replace .= $content;
if (is_array($val) || is_object($val)) {
$replace .= $this->_render($content, $this->getContext($context, $val));
} else {
$replace .= $content;
}
}
break;
}
@@ -411,6 +415,17 @@ class Mustache {
}
}
/**
* Check whether the given $var should be iterated (i.e. in a section context).
*
* @access protected
* @param mixed $var
* @return bool
*/
protected function varIsIterable($var) {
return is_object($var) || (is_array($var) && !array_diff_key($var, array_keys(array_keys($var))));
}
/**
* Prepare a string to be used in a regular expression.
*