|
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 |
mwvdlee Smarty Rookie
Joined: 05 Nov 2011 Posts: 7
|
Posted: Fri May 20, 2016 10:16 pm Post subject: Best way to clone smarty instance |
|
|
I'm currently using `clone` to make copies of a Smarty instance to render multiple templates roughly as such:
Code: |
function getSmarty() {
static $smarty = null;
if (!$smarty) {
$smarty = new Smarty();
// ...all kinds of plugins, and setitngs here...
}
$instance = clone $smarty;
$instance->clearAllAssign();
$instance->clearConfig();
return $instance;
}
|
The primary reason for this construction is to share the compile caching in memory, other than that, the instances should look like clean instances.
The question is; will this work as a way to generate new Smarty instances or will instances returned by this function interfere with each other? Or perhaps there is a better way to do this? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
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
|