Add key/value field names to pairs() in template
parent
b94652978c
commit
edb5c2d45c
|
@ -4,7 +4,7 @@
|
||||||
* Homepage: http://yourcmc.ru/wiki/VMX::Template
|
* Homepage: http://yourcmc.ru/wiki/VMX::Template
|
||||||
* License: GNU GPLv3 or later
|
* License: GNU GPLv3 or later
|
||||||
* Author: Vitaliy Filippov, 2006-2015
|
* 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.
|
* This file contains the implementation of VMX::Template compiler.
|
||||||
* It is only used when a template is compiled in runtime.
|
* It is only used when a template is compiled in runtime.
|
||||||
|
@ -490,7 +490,7 @@ $code
|
||||||
}
|
}
|
||||||
|
|
||||||
/* пары key => ключ, value => значение для ассоциативного массива */
|
/* пары 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()
|
function function_array()
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Homepage: http://yourcmc.ru/wiki/VMX::Template
|
* Homepage: http://yourcmc.ru/wiki/VMX::Template
|
||||||
* License: GNU GPLv3 or later
|
* License: GNU GPLv3 or later
|
||||||
* Author: Vitaliy Filippov, 2006-2015
|
* 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:
|
* The template engine is split into two parts:
|
||||||
* (1) This file - always used when running templates
|
* (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' }
|
// 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();
|
$r = array();
|
||||||
foreach ($array as $k => $v)
|
foreach ($array as $k => $v)
|
||||||
$r[] = array('key' => $k, 'value' => $v);
|
$r[] = array($kf => $k, $vf => $v);
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue