|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
andre Smarty Pro
Joined: 23 Apr 2003 Posts: 164 Location: Karlsruhe, Germany
|
Posted: Mon Sep 29, 2003 11:15 am Post subject: CVS: Bug in simple math and modifiers |
|
|
There's a small bug in simple (inline) math of Smarty CVS using in combination with modifiers:
Main App
[php:1:2aad8960d3]<?php
$smarty = new Smarty();
$smarty->assign("foo", 12345678);
$smarty->display("templates/test.tpl");
?>
[/php:1:2aad8960d3]
Template
Code: | {ldelim}$foo{rdelim} = {$foo}<br/>
{ldelim}$foo/1000{rdelim} = {$foo/1000}<br/>
{ldelim}$foo/1000|number_format:2{rdelim} = {$foo/1000|number_format:2}<br/>
|
Output
Code: | {$foo} = 12345678
{$foo/1000} = 12345.678
{$foo/1000|number_format:2} = 12345678
|
It seems the modifier-regex doesn't cover simple math operations. My outputted template file looks like this:
[php:1:2aad8960d3]<?php /* Smarty version 2.6.0-RC1-cvs, created on 2003-09-29 13:27:08
compiled from templates/test.tpl */ ?>
<?php require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'number_format', 'templates/test.tpl', 3, false),)), $this); ?>
{$foo} = <?php echo $this->_tpl_vars['foo']; ?>
<br/>
{$foo/1000} = <?php echo $this->_tpl_vars['foo']/1000; ?>
<br/>
{$foo/1000|number_format:2} = <?php echo $this->_tpl_vars['foo']/((is_array($_tmp=1000)) ? $this->_run_mod_handler('number_format', true, $_tmp, 2) : smarty_modifier_number_format($_tmp, 2)); ?>
<br/>
[/php:1:2aad8960d3] |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Sep 29, 2003 2:08 pm Post subject: |
|
|
yummy, that's a nice one.
actually this
Code: | {$foo ( /1000|number_format:2 )} |
is what the compiler sees, but you expect this
Code: | { ( $foo/1000 ) |number_format:2} |
to be compiled. |
|
Back to top |
|
Wom.bat Smarty Pro
Joined: 24 Apr 2003 Posts: 107 Location: Munich, Germany
|
Posted: Mon Sep 29, 2003 4:01 pm Post subject: |
|
|
a fix for this issue is in the works... |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Oct 11, 2003 10:02 am Post subject: |
|
|
i committed a fix supplied by dominik.
greetings
messju |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|