Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Smarty: Recompiling File Resource
<?php
/*
This hack is supposed to help using regular file-based templates without writing to compiled_c directory. This should only be used in installers or similar!
*/
// load smarty
require_once '…/Smarty.class.php';
// extend regular File Resource to suggest a source must be recompiled on every invocation
class RecompilingFileResource 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();
// overwrite internal file handler with the one making everything recompile every time
$smarty->registerResource('file', new RecompilingFileResource());
$smarty->display('test.tpl');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.