Created
March 27, 2012 11:19
-
-
Save rodneyrehm/2215060 to your computer and use it in GitHub Desktop.
Smarty: Recompiling File Resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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