X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=template.php;h=fc7302b2ec81edb5ea6ff159f64e9e119cb7c1ac;hb=964ac22b28189d47aa7330dd3d93448b473bfdb9;hp=697761e2962233e0f080332ceab7366744d3ee6d;hpb=7b2c07787abcab33f2e38f1662fc2287befb2794;p=wfpl.git diff --git a/template.php b/template.php index 697761e..fc7302b 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()); @@ -210,10 +212,10 @@ function &tem_row_data($tem, $context) function_exists($auto_func) or die("ERROR: template auto function '$auto_func' not found.
\n"); } - if($auto_func) $value = $auto_func($scope['data'][$key], $key, $scope); + if($auto_func) $value = $auto_func($scope['data'][$key], $key, $scope, $tem['args']); 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;