X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=template.php;h=a20fd64b775964f4ee78e1165961d3ce335f5873;hb=df03dc0feb1ecbab9aa238b46167faca504b1547;hp=697761e2962233e0f080332ceab7366744d3ee6d;hpb=29191174308f52035e427c13f0446d271801e994;p=wfpl.git diff --git a/template.php b/template.php index 697761e..a20fd64 100644 --- a/template.php +++ b/template.php @@ -157,12 +157,14 @@ function &tem_push(&$stack = NULL) { # The middle form will be converted to the last form as we use it. -function tem_data_as_rows($value) { +function tem_data_as_rows($value, $key) { if(is_array($value)) { - # numeric keys, is already array of arrays -- expand sub-template for each. - if(array_key_exists(0, $value)) return $value; + # numeric keys + if(array_key_exists(0, $value)) { + if(is_array($value[0])) return $value; # already array of hashes. + else return columnize($value, $key); # key/value pairs -- expand sub-template once. - else return array($value); + } else return array($value); } elseif($value || $value === 0 || $value === '0' || $value === '') { # value -- expand sub-template once using only parent values return array(array()); @@ -213,7 +215,7 @@ function &tem_row_data($tem, $context) if($auto_func) $value = $auto_func($scope['data'][$key], $key, $scope); else $value = $scope['data'][$key]; - $rows = tem_data_as_rows($value); + $rows = tem_data_as_rows($value, $key); if(is_array($value)) $scope['data'][$key] = $rows; return $rows;