Sets the Twig Environment up
161521
public function setupTwig()
	{
		$twigLoader = new TwigLoader($this->viewManager);
		$config = [];

		if ($this->viewManager->cachePath)
		{
			$config['cache'] = $this->viewManager->cachePath.'twig/';
		}

		$this->twig = new Twig_Environment($twigLoader, $config);
	}
941840
public function renderTwig(\Twig_Environment $environment, $template, array $parameters = array())
    {
        $template = $this->loadStringTemplate($environment, $template);

        return $template->render($parameters);
    }
319920
def setup_app(command, conf, vars):
    """"""
    load_environment(conf.global_conf, conf.local_conf)
    setup_schema(command, conf, vars)
    bootstrap.bootstrap(command, conf, vars)
645110
public function dump(\Twig_Environment $env, $context, ...$vars)
    {
        if (!$env->isDebug()) {
            return null;
        }

        if (!$vars) {
            $vars = [];
            foreach ($context as $key => $value) {
                if (!$value instanceof \Twig_Template) {
                    $vars[$key] = $value;
                }
            }
        }

        ob_start();

        VarDumper::dump($vars);

        echo ob_get_clean();
    }
1145242
public function getTwig(\Twig_Environment $twig)
    {

        $this->functions->rewind();
        while ($this->functions->valid()) {

            $function = $this->functions->current();
            $twig->addFunction(new \Twig_SimpleFunction($function->getFunctionName(), array($function, 'getFunctionBody')));
            $this->functions->next();

        }

        return $twig;

    }
954011
public static function init()
    {
        self::$loader = new Twig_Loader_Filesystem();

        $config = Config::getInstance();

        foreach (array_reverse($config->get('Octo.paths.templates', [])) as $path) {
            self::$loader->addPath($path);
        }

        foreach (array_reverse($config->get('Octo.paths.admin_templates', [])) as $path) {
            self::$loader->addPath($path, 'admin');
        }

        self::$loader->addPath(CMS_PATH . 'Database/Templates/', 'db');

        if (OCTO_CACHE_ENABLED) {
            self::$cache = OCTO_CACHE_PATH;
        } else {
            self::$cache = false;
        }

        self::$twig = new Twig_Environment(self::$loader, [
            'charset' => 'UTF-8',
            'cache' => self::$cache,
            'auto_reload' => true,
            'strict_variables' => false,
        ]);

        $functions = [];
        Event::trigger('TemplateInit', $functions);

        foreach ($functions as $name => $callable) {
            self::addFunction($name, $callable);
        }

        self::$initialised = true;
    }
722267
public function addTwigAssets()
    {
        if (!$this->twig instanceof \Twig_Environment) {
            throw new \LogicException('Twig environment not set');
        }

        $twigNamespaces = $this->loader->getNamespaces();

        foreach ($twigNamespaces as $ns) {

            if ( count($this->loader->getPaths($ns)) > 0 ) {
                $iterator = Finder::create()->files()->in($this->loader->getPaths($ns));

                foreach ($iterator as $file) {
                    $resource = new TwigResource($this->loader, '@' . $ns . '/' . $file->getRelativePathname());
                    $this->lam->addResource($resource, 'twig');
                }
            }
        }
    }
360444
protected function setVars()
    {
        $this->getModel()->setFaIcon('fa-text-width');
        $this->getModel()->setStyle('css'.S.'text.css');
        $this->getModel()->setTemplate('text.html.twig');
    }
692148
public function getTwig(): \Twig_Environment
    {
        if (is_null($this->twig)) {
            // Init Twig
            $this->twigLoader = new \Twig_Loader_Filesystem();
            $this->twig = new \Twig_Environment($this->twigLoader);
        }

        return $this->twig;
    }
839261
public function registerTwigEnvironment()
    {
        $this->app->singleton('twig', function ($app) {
            $twig = new \Twig_Environment(
                $app['twig.loader'],
                [
                    'auto_reload' => true,
                    'cache' => $app['config']['view.twig']
                ]
            );

            // Add Twig Debug Extension
            $twig->addExtension(new \Twig_Extension_Debug());

            // Enable debug.
            if ($app['config']['app.debug']) {
                $twig->enableDebug();
            }

            // Add WordPress helpers extension.
            $twig->addExtension(new WordPress());

            return $twig;
        });
    }
1216470
protected function initEnvironment()
    {
        $this->storedLocale = getenv("LANG");

        $this->log("Setting locale to " . $this->locale, Project::MSG_DEBUG);
        putenv("LANG=" . $this->locale);
        $ret = setlocale(LC_ALL, $this->locale);
        if ($ret === false) {
            $msg = "Could not set locale to " . $this->locale
                . ". You may need to use fully qualified name"
                . " (e.g. en_US instead of en).";
            throw new BuildException($msg);
        }

        $this->log("Binding domain '" . $this->domain . "' to " . $this->dir, Project::MSG_DEBUG);
        bindtextdomain($this->domain, $this->dir->getAbsolutePath());
        textdomain($this->domain);
    }
273239
def _set_env(self, env):
        
        for callback in self.callbacks:
            if callable(getattr(callback, '_set_env', None)):
                callback._set_env(env)
1005036
protected function registerTwigParser()
    {
        /*
         * Register system Twig environment
         */
        App::singleton('twig.environment', function ($app) {
            $twig = new Twig_Environment(new TwigLoader, ['auto_reload' => true]);
            $twig->addExtension(new TwigExtension);
            return $twig;
        });

        /*
         * Register .htm extension for Twig views
         */
        App::make('view')->addExtension('htm', 'twig', function () {
            return new TwigEngine(App::make('twig.environment'));
        });
    }
34208
private function loadStringTemplate(\Twig_Environment $environment, $template)
    {
        $existingLoader = $environment->getLoader();
        $environment->setLoader($this->stringLoader);

        try {
            $template = $environment->loadTemplate($template);
        } catch (\Exception $e) {
            $environment->setLoader($existingLoader);
            
            throw $e;
        }

        $environment->setLoader($existingLoader);

        return $template;
    }
937471
public function renderStripeScripts(Twig_Environment $environment)
    {
        $environment->display($this->scriptsTemplate, [
            'public_key' => $this->publicKey,
            'currency' => $this->paymentBridgeInterface->getCurrency(),
        ]);
    }
325602
protected function initTwig( \Aimeos\MW\View\Iface $view, \Twig_Environment $twig )
	{
		$fcn = function( $key, $default = null ) use ( $view ) {
			return $view->config( $key, $default );
		};
		$twig->addFunction( new \Twig_SimpleFunction( 'aiconfig', $fcn ) );

		$fcn = function( $singular, array $values = array(), $domain = 'client' ) use ( $view ) {
			return vsprintf( $view->translate( $domain, $singular ), $values );
		};
		$twig->addFunction( new \Twig_SimpleFunction( 'aitrans', $fcn ) );

		$fcn = function( $singular, $plural, $number, array $values = array(), $domain = 'client' ) use ( $view ) {
			return vsprintf( $view->translate( $domain, $singular, $plural, $number ), $values );
		};
		$twig->addFunction( new \Twig_SimpleFunction( 'aitransplural', $fcn ) );
	}
357260
public function setTemplate()
    {
        // Creates the loader & sets the template directory path
        $loader = new FilesystemLoader('../src/View');

        // Creates the template engine
        $twig = new Environment($loader, array(
            'cache' => false,
            'debug' => true
        ));

        // Adds Twig extensions
        $twig->addExtension(new DebugExtension());
        $twig->addExtension(new PamTwigExtension());

        // Attributes the template engine to the current object
        $this->twig = $twig;
    }