Skip to content

Instantly share code, notes, and snippets.

@rodneyrehm
Created March 27, 2012 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodneyrehm/2215060 to your computer and use it in GitHub Desktop.
Save rodneyrehm/2215060 to your computer and use it in GitHub Desktop.
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