garvinhicking wrote:Ian, would you like to pester Rodney Rehm with that?
No! I would not like to be the one for pestering issues..!
Eval is a performance buster, a security issue and not being used any more. There is a new eval resource which still provides the old behaviour. We could use
Code: Select all
try {
$smarty->fetch('eval:'. $templateString);
// everything is fine…
} catch(SmartyException $e) {
// error occured
}
or
Code: Select all
// eval a string template and do not store compiled code
$smarty->display('eval:'.$string);
// display string template and store compiled code
$smarty->display('string:'.$string);
On the other hand..., PHP 5.1 introduced two new streams, php://memory and php://temp. The first will write everything to memory. But this needs php.ini allowed memory size to have enough RAM available. That would be nice to have here, but it seems mkdir() and other functions being used in the Smarty_Internal_Write_File class are not supported by these streams yet.
Rodney once wrote to this kind of problem:
Code: Select all
A very simple solution to your problem would be to extend the internal file resource and simply make it recompiling:
Code:
require_once '…/Smarty.class.php';
class EvaledFileResource extends Smarty_Internal_Resource_File {
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null) {
parent::populate($source, $_template);
$source->recompiled = true;
}
}
$smarty = new Smarty();
$smarty
->setTemplateDir('./templates')
->registerResource('file', new EvaledFileResource());
$smarty
->assign('foo', 'hello world')
->display('test.tpl');
So what about these ones, Garvin?
But as I said already, I am going to have a look on this, as this is the installer procedure only and as soon the prototype is ready. For me - at the moment - it seems much simpler, more robust, easier and flexible to just use a raw PHP template in this special case instead. It could reside in the tpl dir too, look nearly the same as the smarty one and would save a lot of energy working around problems and performance issues.
@YL
I am a peaceful man. No military terminology is needed to declare that I was off for a few days, gladly.
I even remember to have said and left that somewhere... but good that Malte solved your problem!