|
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 |
mataniko Smarty n00b
Joined: 31 Jul 2018 Posts: 3
|
Posted: Wed May 01, 2019 3:20 am Post subject: Template variable in configuration string. |
|
|
Is there a way to expand a variable referenced in a configuration string? For example:
Code: |
// sample.php
$smarty->assign(array( 'release' => '2.0.0' )
// sample.ini
info=Version {$release}
// sample.tpl
<span>{#info#}</span>
|
Output
Code: | <span>Version {$release}</span> |
Desired output:
Code: | <span>Version 2.0.0</span> |
Thank you |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed May 01, 2019 11:08 am Post subject: |
|
|
That's inadvisable but possible.
Code: | {include "string:{#info#}"} |
|
|
Back to top |
|
mataniko Smarty n00b
Joined: 31 Jul 2018 Posts: 3
|
Posted: Wed May 01, 2019 1:07 pm Post subject: |
|
|
Thanks. I was hoping there was a more straightforward way to do this, one which wouldn't require the template writer to know which string variable has a string variable in it.
Would this be something considered for a future version? If so, I'd look into making a PR for this. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri May 03, 2019 6:37 am Post subject: |
|
|
No. Configuration settings are variables.
Template can't possible know which variables contain other vriables, or it would blow up from infinite recursion. |
|
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
|