From edb5c2d45ceea4c190614f3386def92195bbe31f Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Mon, 25 May 2015 18:41:15 +0300 Subject: [PATCH] Add key/value field names to pairs() in template --- template.parser.php | 4 ++-- template.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/template.parser.php b/template.parser.php index b699084..ef1a27f 100644 --- a/template.parser.php +++ b/template.parser.php @@ -4,7 +4,7 @@ * Homepage: http://yourcmc.ru/wiki/VMX::Template * License: GNU GPLv3 or later * Author: Vitaliy Filippov, 2006-2015 - * Version: V3 (LALR), 2015-04-12 + * Version: V3 (LALR), 2015-05-25 * * This file contains the implementation of VMX::Template compiler. * It is only used when a template is compiled in runtime. @@ -490,7 +490,7 @@ $code } /* пары key => ключ, value => значение для ассоциативного массива */ - function function_pairs($a) { return "self::exec_pairs(is_array($a) ? $a : array())"; } + function function_pairs() { $a = func_get_args(); return "self::exec_pairs(".implode(', ', $a).")"; } /* создание массива */ function function_array() diff --git a/template.php b/template.php index 7e16ee4..09daf0a 100644 --- a/template.php +++ b/template.php @@ -8,7 +8,7 @@ * Homepage: http://yourcmc.ru/wiki/VMX::Template * License: GNU GPLv3 or later * Author: Vitaliy Filippov, 2006-2015 - * Version: V3 (LALR), 2015-04-12 + * Version: V3 (LALR), 2015-05-25 * * The template engine is split into two parts: * (1) This file - always used when running templates @@ -584,11 +584,11 @@ class VMXTemplate } // For a hash, returns an array with pairs { key => 'key', value => 'value' } - static function exec_pairs($array) + static function exec_pairs($array, $kf = 'key', $vf = 'value') { $r = array(); foreach ($array as $k => $v) - $r[] = array('key' => $k, 'value' => $v); + $r[] = array($kf => $k, $vf => $v); return $r; }