Permalink
Browse files

twig works without cache folder too now

  • Loading branch information...
1 parent 164bc03 commit a7e1289e97d5bd467391698f0efcb5083109eccf Armin Ronacher committed Apr 15, 2008
Showing with 8 additions and 1 deletion.
  1. +8 −1 php/Twig/api.php
View
@@ -91,7 +91,14 @@ public function requireTemplate($name)
if (!file_exists($cache_fn) ||
filemtime($cache_fn) < filemtime($fn)) {
twig_load_compiler();
- $fp = fopen($cache_fn, 'wb');
+ $fp = @fopen($cache_fn, 'wb');
+ /* looks like we don't have access to this file.
+ In that case we just load the code from memory */
+ if (!$fp) {
+ $code = $this->compileTemplate($name, NULL, $fn);
+ eval('?>' . $code);
+ return $cls;
+ }
$compiler = new Twig_FileCompiler($fp);
$this->compileTemplate($name, $compiler, $fn);
fclose($fp);

0 comments on commit a7e1289

Please sign in to comment.