public function render($name, array $values = array()) { if (defined('ENV_DEV')) { $this->engine->clearCacheFiles(); $this->engine->clearTemplateCache(); } return $this->engine->render($name . $this->suffix, $values); }
/** * Initialise Twig * * @return void */ protected function initTemplateEngine() { $this->loader = new \Twig_Loader_Filesystem($this->getTemplateDir()); $this->twig = new \Twig_Environment($this->loader, array('cache' => $this->cacheDir)); if ($this->isDev) { $this->twig->clearCacheFiles(); } }
/** * Clear the cache * * @return \phpbb\template\template */ public function clear_cache() { if (is_dir($this->cachepath)) { $this->twig->clearCacheFiles(); } return $this; }
/** * sends content to the browser */ function render($string, $template_vars = array()) { $loader = new \Twig_Loader_Filesystem($this->templates); $twig = new \Twig_Environment($loader, array('cache' => __ROOT__ . '/cache/twig')); if (__DEV__) { $twig->clearCacheFiles(); } echo $twig->render($string, $template_vars); }
/** * @param $rootDir * @param $loader * @return Twig_Environment */ protected function getTwig($rootDir, $loader) { $twig = new Twig_Environment($loader, array('cache' => $rootDir . '/cache/')); $twig->clearCacheFiles(); $f = new Twig_SimpleFunction("querify", function ($data) { $string = array(); foreach ($data as $d) { $string[] = urlencode($d->key) . "=" . urlencode($d->value); } return implode("&", $string); }); $twig->addFunction("querify", $f); $f = new Twig_SimpleFunction("prettify", function ($data) { return json_encode(json_decode($data), JSON_PRETTY_PRINT); }); $twig->addFunction("prettify", $f); return $twig; }
*/ include_once '../vendor/autoload.php'; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\DomCrawler\Crawler; use Evista\Perform\Service; use Evista\Perform\Exception\FormFieldException; date_default_timezone_set('Europe/Budapest'); $router = new League\Route\RouteCollection(); $loader = new Twig_Loader_Filesystem('../src/views'); $crawler = new Crawler(); // Initialize form transpilation service (dependency injection friendly interface) $formService = new Service($crawler, '../var/uploads'); $twig = new Twig_Environment($loader, array('cache' => '../var/cache')); $twig->clearCacheFiles(); $router->addRoute('GET', '/', function (Request $request, Response $response) use($twig) { // do something clever $response = new Response($twig->render('form.twig.html', [])); return $response; }); $router->addRoute('POST', '/displayform', function (Request $request, Response $response) use($twig, $crawler, $formService) { $formMarkup = $request->request->get('serform'); $form = $formService->transpileForm($formMarkup); // Dump the object $response = new JsonResponse(['dump' => var_export($form, true)]); return $response; }); // Use form data $router->addRoute('POST', '/multiple-file-uploads', function (Request $request, Response $response) use($twig, $crawler, $formService) { $formMarkup = urldecode($request->request->get('serform'));
/** * Очистка кеша шаблонов */ public static function clearCacheFiles() { self::$twigEnvironment->clearCacheFiles(); }
/** * [clearCacheFiles description] * @return [type] [description] */ public function clearCacheFiles() { $this->twig->clearCacheFiles(); }
/** * @return void */ public function clearCache() { $E = new \Twig_Environment(null, array('cache' => realpath(__DIR__ . self::$Cache))); $E->clearCacheFiles(); $E->clearTemplateCache(); }
/** * {@inheritdoc} */ public function reset() { $this->twig->clearCacheFiles(); $this->twig->clearTemplateCache(); }