From e47e159ee6d2ee623de50b722d5e3b41835402f0 Mon Sep 17 00:00:00 2001 From: paw34rus Date: Thu, 30 Jan 2014 19:57:56 -0800 Subject: [PATCH 1/8] Update raw.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit опечатка --- docs/tags/raw.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tags/raw.md b/docs/tags/raw.md index c3b3db3..d17bdf9 100644 --- a/docs/tags/raw.md +++ b/docs/tags/raw.md @@ -1,7 +1,7 @@ Tag {raw} [RU] ================== -Тег `{raw }` позволяет выводить результат выражения или функций без экранирования, игнорируя глобальную настройку `auto_secape`. +Тег `{raw }` позволяет выводить результат выражения или функций без экранирования, игнорируя глобальную настройку `auto_escape`. ```smarty {autoescape true} @@ -26,4 +26,4 @@ Tag {raw} [RU] {/autoescate} ``` -На компиляторы свойство raw не распространяется. \ No newline at end of file +На компиляторы свойство raw не распространяется. From 558cafc1fed4ce294aebcebdf6bf183ed8e202db Mon Sep 17 00:00:00 2001 From: Ivan Shalganov Date: Fri, 7 Feb 2014 22:44:03 +0300 Subject: [PATCH 2/8] Update usage.md --- docs/usage.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index a7eff94..e008084 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -3,31 +3,31 @@ Basic usage ### Initialize Fenom -Use factory method +Creating an object via factory method ```php $fenom = Fenom::factory('/path/to/templates', '/path/to/compiled/template', $options); ``` -Use `new` operator +Creating an object via `new` operator ```php $fenom = new Fenom(new Provider('/path/to/templates')); $fenom->setCompileDir('/path/to/template/cache'); $fenom->setOptions($options); ``` -### Render template +### Rendering template Output template ```php $fenom->display("template/name.tpl", $vars); ``` -Get template into the variable +Get the result of rendering the template ```php $result = $fenom->fetch("template/name.tpl", $vars); ``` -Create pipe-line into callback +Create the pipeline of rendering into callback ```php $fenom->pipe( "template/sitemap.tpl", From df5fb0516d53f9017f3f9ab105f3ec8172d862c0 Mon Sep 17 00:00:00 2001 From: igorhim Date: Tue, 18 Feb 2014 23:48:56 +0200 Subject: [PATCH 3/8] Fix custom modifier closure functions call --- src/Fenom/Template.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Fenom/Template.php b/src/Fenom/Template.php index fe6f025..8ff44e0 100644 --- a/src/Fenom/Template.php +++ b/src/Fenom/Template.php @@ -1173,6 +1173,7 @@ class Template extends Render if (!$mods) { throw new \Exception("Modifier " . $tokens->current() . " not found"); } + $modifier = $tokens->current(); $tokens->next(); $args = array(); @@ -1183,7 +1184,7 @@ class Template extends Render } if (!is_string($mods)) { // dynamic modifier - $mods = 'call_user_func($tpl->getStorage()->getModifier("' . $mods . '"), '; + $mods = 'call_user_func($tpl->getStorage()->getModifier("' . $modifier . '"), '; } else { $mods .= "("; } From 65477a5a06b32de25dd5bf7aa3a38583e09088d9 Mon Sep 17 00:00:00 2001 From: igorhim Date: Tue, 18 Feb 2014 23:53:02 +0200 Subject: [PATCH 4/8] Fix warning object to string --- src/Fenom/Template.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Fenom/Template.php b/src/Fenom/Template.php index 8ff44e0..0f2d524 100644 --- a/src/Fenom/Template.php +++ b/src/Fenom/Template.php @@ -492,11 +492,11 @@ class Template extends Render return $this->out($this->parseExpr($tokens), $tokens); } } catch (InvalidUsageException $e) { - throw new CompileException($e->getMessage() . " in {$this} line {$this->_line}", 0, E_ERROR, $this->_name, $this->_line, $e); + throw new CompileException($e->getMessage() . " in {$this->_name} line {$this->_line}", 0, E_ERROR, $this->_name, $this->_line, $e); } catch (\LogicException $e) { - throw new SecurityException($e->getMessage() . " in {$this} line {$this->_line}, near '{" . $tokens->getSnippetAsString(0, 0) . "' <- there", 0, E_ERROR, $this->_name, $this->_line, $e); + throw new SecurityException($e->getMessage() . " in {$this->_name} line {$this->_line}, near '{" . $tokens->getSnippetAsString(0, 0) . "' <- there", 0, E_ERROR, $this->_name, $this->_line, $e); } catch (\Exception $e) { - throw new CompileException($e->getMessage() . " in {$this} line {$this->_line}, near '{" . $tokens->getSnippetAsString(0, 0) . "' <- there", 0, E_ERROR, $this->_name, $this->_line, $e); + throw new CompileException($e->getMessage() . " in {$this->_name} line {$this->_line}, near '{" . $tokens->getSnippetAsString(0, 0) . "' <- there", 0, E_ERROR, $this->_name, $this->_line, $e); } } From 1f9a56500e5ce167a07089705de0db6bfd2d2a91 Mon Sep 17 00:00:00 2001 From: Ivan Shalganov Date: Wed, 9 Apr 2014 20:00:08 +0400 Subject: [PATCH 5/8] Fix #75: throw invalid exception --- src/Fenom/Render.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Fenom/Render.php b/src/Fenom/Render.php index 138af26..ea073d2 100644 --- a/src/Fenom/Render.php +++ b/src/Fenom/Render.php @@ -9,7 +9,6 @@ */ namespace Fenom; use Fenom; -use Symfony\Component\Yaml\Exception\RuntimeException; /** * Primitive template @@ -194,13 +193,14 @@ class Render extends \ArrayObject /** * Get internal macro - * @param $name - * @return mixed + * @param string $name + * @throws \RuntimeException + * @return array */ public function getMacro($name) { if (empty($this->_macros[$name])) { - throw new RuntimeException('macro not found'); + throw new \RuntimeException('macro '.$name.' not found'); } return $this->_macros[$name]; } From e9a60041c4bc529a68d6bad0ab0c9aa5031db939 Mon Sep 17 00:00:00 2001 From: Ivan Shalganov Date: Wed, 9 Apr 2014 20:01:20 +0400 Subject: [PATCH 6/8] Fix #75: macros don's share between child and parent templates --- src/Fenom/Compiler.php | 1 + src/Fenom/Template.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Fenom/Compiler.php b/src/Fenom/Compiler.php index 0fe0c30..9e0344a 100644 --- a/src/Fenom/Compiler.php +++ b/src/Fenom/Compiler.php @@ -517,6 +517,7 @@ class Compiler $t->_extended = true; $tpl->addDepend($t); $t->_compatible = & $tpl->_compatible; + $t->macros = & $tpl->macros; $t->blocks = & $tpl->blocks; $t->compile(); if ($t->uses) { diff --git a/src/Fenom/Template.php b/src/Fenom/Template.php index fe6f025..4803063 100644 --- a/src/Fenom/Template.php +++ b/src/Fenom/Template.php @@ -1254,6 +1254,7 @@ class Template extends Render $macro = false; if (isset($this->macros[$name])) { $macro = $this->macros[$name]; + $recursive = $macro['recursive']; } else { foreach ($this->_stack as $scope) { if ($scope->name == 'macro' && $scope['name'] == $name) { // invoke recursive @@ -1280,8 +1281,10 @@ class Template extends Render } $n = sprintf('%u_%d', crc32($this->_name), $this->i++); if ($recursive) { - $recursive['recursive'] = true; $body = '$tpl->getMacro("' . $name . '")->__invoke($tpl);'; + if($recursive instanceof Scope) { + $recursive['recursive'] = true; + } } else { $body = '?>' . $macro["body"] . ' Date: Wed, 9 Apr 2014 20:04:38 +0400 Subject: [PATCH 7/8] Update doc for macros --- docs/tags/macro.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/tags/macro.md b/docs/tags/macro.md index bac80f2..b1c750a 100644 --- a/docs/tags/macro.md +++ b/docs/tags/macro.md @@ -20,7 +20,15 @@ Tag {macro} [RU] {macro.plus x=$num y=100} ``` -На данный момент рекурсивный вызов макроса не поддерживается. +Во время рекурсивного вызова используйте суффикс macro что бы обратиться к текущему макросу: + +```smarty +{macro plus(x, y, z=0)} + ... + {macro.plus x=2 y=4} + ... +{/macro} +``` ### {import} From aeda090476d3b88f5c05dcd16907c9fcecf91196 Mon Sep 17 00:00:00 2001 From: Ivan Shalganov Date: Wed, 9 Apr 2014 20:07:37 +0400 Subject: [PATCH 8/8] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d46f8fc..60a90cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +### 1.4.9 (2013-04-09) + +- Fix #75 +- Docs++ + ### 1.4.8 (2013-12-01) - Fix #52