From 78fd3b1e2d08b9fc13d7e7eadaed824f38234de0 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Tue, 30 Jul 2013 22:50:25 +0300 Subject: [PATCH] simplify template modifiers code --- ipf/template/compiler.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ipf/template/compiler.php b/ipf/template/compiler.php index 920320f..c258fa9 100644 --- a/ipf/template/compiler.php +++ b/ipf/template/compiler.php @@ -220,17 +220,22 @@ class IPF_Template_Compiler trigger_error(sprintf(__('Invalid modifier syntax: (%s) %s'), $expr, $modifier), E_USER_ERROR); return ''; } - $targs = array($res); - if (isset($m[2])) { - $res = $this->_modifier[$m[1]].'('.$res.','.$m[2].')'; - } elseif (isset($this->_modifier[$m[1]])) { - $res = $this->_modifier[$m[1]].'('.$res.')'; - } else { + + if (isset($this->_modifier[$m[1]])) { trigger_error(sprintf(__('Unknown modifier: (%s) %s'), $expr, $m[1]), E_USER_ERROR); return ''; } - if (!in_array($this->_modifier[$m[1]], $this->_usedModifiers)) { - $this->_usedModifiers[] = $this->_modifier[$m[1]]; + + $modifier = $this->_modifier[$m[1]]; + + if (isset($m[2])) { + $res = $modifier.'('.$res.','.$m[2].')'; + } else { + $res = $modifier.'('.$res.')'; + } + + if (!in_array($modifier, $this->_usedModifiers)) { + $this->_usedModifiers[] = $modifier; } } return $res; -- 2.49.0