|
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 |
peregrin Smarty n00b
Joined: 16 Apr 2007 Posts: 1
|
Posted: Mon Apr 16, 2007 8:47 am Post subject: Variables with minus char |
|
|
PHP
Code: |
$test['var-with-minus'] = 'testvar';
$this->assign('test',$test);
|
Template:
Code: | {$test.var-with-minus} |
This return '0'
Compile file contain:
Code: | <?php echo $this->_tpl_vars['test']['var']-$this->_tpl_vars['ith']-$this->_tpl_vars['inus']; ?> |
And:
Code: |
$test['var-with-minus'] = 'testvar';
$this->assign('test',$test);
$this->assign('inus',100);
$this->assign('ith',-7);
|
Return: -93 |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Apr 17, 2007 3:31 pm Post subject: |
|
|
Hi. Thanks for taking the time to submit this but this a feature request rather than a bug. Key names must follow var name conventions if you want to access them lexically.
The workaround is to rename your incoming keys or to use temporary assignments in your template to represent unusuable keynames. Finally, you can consider a custom modifier such as the "lookup" modifier (search the forums) or something more radical like the "from" modifier (also search the forums). |
|
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
|