$body), array( 'key' => $key, 'lifetime' => $lifetime), $lineno, $tag); } /** * {@inheritDoc} */ public function compile(Compiler $compiler) { $boo = $this->getAttribute('key'); $compiler ->addDebugInfo($this) ->write("\$cache = \\Grav\\Common\\Grav::instance()['cache'];\n") ->write("\$key = \"twigcache-\" . \"" . $this->getAttribute('key') . "\";\n") ->write("\$lifetime = " . $this->getAttribute('lifetime') . ";\n") ->write("\$cache_body = \$cache->fetch(\$key);\n") ->write("if (\$cache_body === false) {\n") ->indent() ->write("ob_start();\n") ->indent() ->subcompile($this->getNode('body')) ->outdent() ->write("\n") ->write("\$cache_body = ob_get_clean();\n") ->write("\$cache->save(\$key, \$cache_body, \$lifetime);\n") ->outdent() ->write("}\n") ->write("echo \$cache_body;\n") ; } }