JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Josh's fix for tem_set(array(1,2,3))
authorJason Woofenden <jason@jasonwoof.com>
Sun, 28 Aug 2011 21:34:15 +0000 (17:34 -0400)
committerJason Woofenden <jason@jasonwoof.com>
Mon, 19 Sep 2011 18:20:13 +0000 (14:20 -0400)
template.php

index 697761e..a20fd64 100644 (file)
@@ -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;