mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-05 13:04:23 +02:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 46e571fedd | |||
| 15e48b6af3 | |||
| d5adea5863 | |||
| 8041d0a4e8 | |||
| 94d9861d29 | |||
| 63ff7d81e0 | |||
| e6b6a0cbb2 | |||
| 0912124c33 | |||
| 1820e875dc |
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Fixed
|
||||
- The {debug} tag was broken in v5 [#922](https://github.com/smarty-php/smarty/issues/922)
|
||||
- Documentation on `{if $x is even by $y}` syntax
|
||||
|
||||
## [5.0.0-rc2] - 2023-11-11
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
- Fix incorrect compilation of expressions when escape_html=true [#930](https://github.com/smarty-php/smarty/pull/930)
|
||||
@@ -10,4 +10,7 @@ template.
|
||||
{$foo:bar}
|
||||
```
|
||||
|
||||
NB. Support for using streams to call variables is deprecated since Smarty v5.1 and will be removed
|
||||
in a future version.
|
||||
|
||||
See also [`Template Resources`](../resources.md)
|
||||
|
||||
@@ -252,7 +252,7 @@ iteration.
|
||||
|
||||
```smarty
|
||||
{foreach $myNames as $name}
|
||||
{if $name@iteration is even by 3}
|
||||
{if $name@index is even by 3}
|
||||
<span style="color: #000">{$name}</span>
|
||||
{else}
|
||||
<span style="color: #eee">{$name}</span>
|
||||
|
||||
@@ -478,13 +478,13 @@ header block every five rows.
|
||||
</table>
|
||||
```
|
||||
|
||||
An example that uses the `iteration` property to alternate a text color every
|
||||
An example that uses the `index` property to alternate a text color every
|
||||
third row.
|
||||
|
||||
```smarty
|
||||
<table>
|
||||
{section name=co loop=$contacts}
|
||||
{if $smarty.section.co.iteration is even by 3}
|
||||
{if $smarty.section.co.index is even by 3}
|
||||
<span style="color: #ffffff">{$contacts[co].name}</span>
|
||||
{else}
|
||||
<span style="color: #dddddd">{$contacts[co].name}</span>
|
||||
|
||||
@@ -84,7 +84,7 @@ class PrintExpressionCompiler extends Base {
|
||||
}
|
||||
|
||||
if ($compiler->getTemplate()->getSmarty()->escape_html) {
|
||||
$output = "htmlspecialchars((string) {$output}, ENT_QUOTES, '" . addslashes(\Smarty\Smarty::$_CHARSET) . "')";
|
||||
$output = "htmlspecialchars((string) ({$output}), ENT_QUOTES, '" . addslashes(\Smarty\Smarty::$_CHARSET) . "')";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -555,6 +555,9 @@ class Template extends TemplateBase {
|
||||
*/
|
||||
public function getStreamVariable($variable)
|
||||
{
|
||||
|
||||
trigger_error("Using stream variables (\`\{\$foo:bar\}\`)is deprecated.", E_USER_DEPRECATED);
|
||||
|
||||
$_result = '';
|
||||
$fp = fopen($variable, 'r+');
|
||||
if ($fp) {
|
||||
|
||||
@@ -103,7 +103,37 @@ class CompileIfTest extends PHPUnit_Smarty
|
||||
array('{if 6 is not even}yes{else}no{/if}', 'no', 'IsNotEven', $i ++),
|
||||
array('{if 3 is odd}yes{else}no{/if}', 'yes', 'IsOdd', $i ++),
|
||||
array('{if 3 is not odd}yes{else}no{/if}', 'no', 'IsNotOdd', $i ++),
|
||||
array('{$foo=3}{if 3 is odd by $foo}yes{else}no{/if}', 'yes', 'IsOddByVar', $i ++),
|
||||
|
||||
array('{if 0 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByTest0', $i ++),
|
||||
array('{if 1 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByTest1', $i ++),
|
||||
array('{if 2 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByTest2', $i ++),
|
||||
array('{if 3 is even by 3}yes{else}no{/if}', 'no', 'IsEvenByTest3', $i ++),
|
||||
array('{if 4 is even by 3}yes{else}no{/if}', 'no', 'IsEvenByTest4', $i ++),
|
||||
array('{if 5 is even by 3}yes{else}no{/if}', 'no', 'IsEvenByTest5', $i ++),
|
||||
array('{if 6 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByTest6', $i ++),
|
||||
array('{if 7 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByTest7', $i ++),
|
||||
|
||||
array('{if 0 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByTest0', $i ++),
|
||||
array('{if 1 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByTest1', $i ++),
|
||||
array('{if 2 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByTest2', $i ++),
|
||||
array('{if 3 is odd by 3}yes{else}no{/if}', 'yes', 'IsOddByTest3', $i ++),
|
||||
array('{if 4 is odd by 3}yes{else}no{/if}', 'yes', 'IsOddByTest4', $i ++),
|
||||
array('{if 5 is odd by 3}yes{else}no{/if}', 'yes', 'IsOddByTest5', $i ++),
|
||||
array('{if 6 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByTest6', $i ++),
|
||||
array('{if 7 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByTest7', $i ++),
|
||||
|
||||
array('{if 2 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByVal1', $i ++),
|
||||
array('{if 3 is even by 2}yes{else}no{/if}', 'no', 'IsEvenByVal2', $i ++),
|
||||
array('{if 4 is even by 3}yes{else}no{/if}', 'no', 'IsEvenByVal3', $i ++),
|
||||
array('{$foo=3}{if 2 is even by $foo}yes{else}no{/if}', 'yes', 'IsEvenByVar1', $i ++),
|
||||
array('{$foo=2}{if 3 is even by $foo}yes{else}no{/if}', 'no', 'IsEvenByVar2', $i ++),
|
||||
array('{$foo=3}{if 4 is even by $foo}yes{else}no{/if}', 'no', 'IsEvenByVar3', $i ++),
|
||||
array('{if 2 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByVal1', $i ++),
|
||||
array('{if 3 is odd by 2}yes{else}no{/if}', 'yes', 'IsOddByVal2', $i ++),
|
||||
array('{if 4 is odd by 3}yes{else}no{/if}', 'yes', 'IsOddByVal3', $i ++),
|
||||
array('{$foo=3}{if 2 is odd by $foo}yes{else}no{/if}', 'no', 'IsOddByVar1', $i ++),
|
||||
array('{$foo=2}{if 3 is odd by $foo}yes{else}no{/if}', 'yes', 'IsOddByVar2', $i ++),
|
||||
array('{$foo=3}{if 4 is odd by $foo}yes{else}no{/if}', 'yes', 'IsOddByVar3', $i ++),
|
||||
array('{$foo=3}{$bar=6}{if $bar is not odd by $foo}yes{else}no{/if}', 'yes', 'IsNotOddByVar', $i ++),
|
||||
array('{$foo=3}{$bar=3}{if 3+$bar is not odd by $foo}yes{else}no{/if}', 'yes', 'ExprIsNotOddByVar', $i ++),
|
||||
array('{$foo=2}{$bar=6}{if (3+$bar) is not odd by ($foo+1)}yes{else}no{/if}', 'no', 'ExprIsNotOddByExpr', $i ++),
|
||||
|
||||
Reference in New Issue
Block a user