@param string $template
@param string $file
@param array  $parameters

@return OutputFile
320341
protected function generateOutputFile($template, $file, array $parameters)
    {
        $template = sprintf('%s/%s', static::LANGUAGE, $template);
        $content = $this->render($template, $parameters);
        $ext = static::EXTENSION;
        $addNewLine = static::LANGUAGE !== 'json-schema';
        return new OutputFile(
            "{$this->compileOptions->getOutput()}/{$file}$ext",
            trim($content) . ($addNewLine ? PHP_EOL : '')
        );
    }
689121
public static function template(
        $template,
        $parameters,
        $startChar = '%',
        $endChar = '%'
    ) {
        foreach ($parameters as $key => $value) {
            $template = str_replace($startChar . $key . $endChar, $value, $template);
        }
        return $template;
    }
1012650
private function getExportCommand(array $parameter, $file, $hidePassword = false)
    {
        $username = $parameter['username'];
        $password = $parameter['password'];
        $database = $parameter['database'];
        $host = $parameter['host'];
        $port = $parameter['port'];

        return sprintf(
            'mysqldump -u%s%s%s%s %s > %s',
            $username,
            isset($password) ? (' -p' . ($hidePassword ? '***' : "'" . addcslashes($password, "'") . "'")) : '',
            isset($host) ? (' -h ' . $host) : '',
            isset($port) ? (' -P ' . $port) : '',
            $database,
            $file
        );
    }
180366
public function templateFile($path, array $arguments = [])
    {
        $this->file($path)->template($this->makePath($path), $arguments);
    }
60765
private function composeTemplateContent(
        FileSystemInterface $fileSystem,
        string $templatePath,
        iterable $templateParams
    ): string {
        $templateContent = $fileSystem->read($templatePath);

        foreach ($templateParams as $key => $value) {
            $templateContent = str_replace($key, $value, $templateContent);
        }

        return $templateContent;
    }
1299037
public function makeHtml($template, $data=null)
	{
		$content = $this->render($template, $data);
		return File::write($this->getHtmlFile($template), $content); 
	}
400712
public function fakeTemplate($file)
    {
        $this->template->loadTemplate($file);
        $varsName = $this->template->getVariables();
        $out = '';
        $num = $this->num;
        for ($i = 0; $i < $num; $i++) {
            $fakeData = $this->num(1)->fake($varsName)->toArray();
            $data = array_combine(array_values($varsName), $fakeData);
            $out .= $this->template->render($data);
        }

        return $out;
    }
847364
public function display ($file, $output = TRUE)
	{

		// If there is no template directory set then try and use default root/templates directory

		if (!$this->templateDir)
		{
			$this->templateDir	= ABS_ROOT . 'templates' . DIRECTORY_SEPARATOR;
		}

		// Load template

		$template	= $this->loadTemplateFile ($file);

		// Replace variables

		if ($this->replaceVars)
		{
			$rendered	= $this->replaceVars ($template);
		} else {
			$rendered	 = $template;
		}

		// Output

		if ($output)
		{
			echo $rendered;
		}

		// Return template

		return $rendered;

	}
351270
public function renderString($template, array $params = null)
    {
        if (! empty($params)) {
            $this->assign($params);
        }

        $compiled = $this->getCompiler()->compile($template);

        $tempFile = tempnam(sys_get_temp_dir(), __FUNCTION__);

        $this->writeToFile($tempFile, $compiled);

        $template = $this->readBuffer($tempFile);

        unlink($tempFile);

        return $template;
    }
1009324
public function generateFile($filename, $templateData, $templatePath = null)
    {
        $this->makeDirectory($this->rootPath);

        $path = $this->rootPath.$filename;

        if (is_null($templatePath)) {
            $templatePath = $this->templatePath;
        }
        
        $content = $this->generateContent($templatePath, $templateData);

        if (! file_exists($path)) {
            $this->fileHelper->put($path, $content);
            $this->command->info($filename.' created successfully.');
        } else {
            $this->command->info($filename.' already exists ... skipping.');
        }
    }
799827
private function translate(string $template, array $parameters): string
    {
        $placeholders = array_map([$this, 'getPlaceholder'], array_keys($parameters));
        $replacements = array_map([$this, 'getTranslatedValue'], array_values($parameters));

        return str_replace($placeholders, $replacements, $template);
    }
169636
protected function findTemplateFile($file)
    {
        //Add missing extension
        $ext = pathinfo($file, PATHINFO_EXTENSION);
        $file = ($ext === '') ? $file . '.'.$this->getExtension() : $file;

        $found = false;
        foreach ($this->locations as $location) {
            if (is_file($location . '/' . $file)) {
                $found = true;
                $file = $location . '/' . $file;
                continue;
            }
        }

        if (!$found) {
            throw new TemplateNotFoundException('This template was not found in any of the registered locations: ' . $file);
        }

        return $file;
    }
358416
public function render($file, $vars = null) 
    {
        $template = '';

        if (is_null($this->templatesPath)) {
            throw new \LogicException('Variable "templatesPath" can\'t be NULL.');
        } else if (is_string($this->templatesPath) && !file_exists($this->templatesPath)) {
            throw new \LogicException(sprintf('Folder "%s" don\'t exists.', $this->templatesPath));
        } else if (is_array($this->templatesPath)) {
            foreach ($this->templatesPath as $folderPath) {
                if (file_exists($template = "$folderPath/{$file}")) {
                    break;
                }
            }
        }
        
        if (!$template) {
            $template = "$this->templatesPath/{$file}";
        }
        
        if(!file_exists($template)){
           throw new \LogicException(sprintf('View "%s" don\'t exists.', $template));
        }
        
        if (is_array($vars)) {
            extract($vars);
            foreach ($vars as $key => $value) {
                $key = $value;
            }
        }        
        
        ob_start();
        require $template;
        return ob_get_clean();
    }
1133268
public function getParameterSets($file, $paramProviders)
    {
        $parameterSets = $this->launcher->payload(__DIR__ . '/template/parameter_set_extractor.template', [
            'file' => $file,
            'class' => $this->getClassNameFromFile($file),
            'paramProviders' => var_export($paramProviders, true),
        ])->launch();

        // validate parameters
        $parameters = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($parameterSets));
        iterator_apply($parameters, function (\Iterator $iterator) {
            $parameter = $iterator->current();

            if (!is_scalar($parameter) && isset($parameter)) {
                throw new \InvalidArgumentException(sprintf(
                    'Parameter values must be scalar. Got "%s"',
                    is_object($parameter) ? get_class($parameter) : gettype($parameter)
                ));
            }
        }, [$parameters]);

        return $parameterSets;
    }
599459
public static function create_template($template) {
        global $PAGE;

        $params = self::validate_parameters(self::create_template_parameters(), array('template' => $template));
        $params = $params['template'];
        $context = self::get_context_from_params($params);
        self::validate_context($context);
        $output = $PAGE->get_renderer('core');

        unset($params['contextlevel']);
        unset($params['instanceid']);
        $params = (object) $params;
        $params->contextid = $context->id;

        $result = api::create_template($params);
        $exporter = new template_exporter($result);
        $record = $exporter->export($output);
        return $record;
    }
1256928
protected function generateFromTemplate($template, $fileName, $path)
    {
        $file = $this->loadTemplate($template);
        $content = $this->replaceValues( $file );
        $this->createFile( $fileName, $path, $content );

        return true;
    }
416270
public function renderTemplate($filename, array $templateDir, array $params = [], array $vars = [])
    {
        $this->addDirPathIntoLoaderIfNotExists($templateDir);
        $render = '';
        try {
            $params['this'] = $this;
            $params = array_merge($params, $vars);

            try {
                $render = $this->twig->render($filename, $params);
            } catch (\Twig_Error_Runtime $e) {
                if($e->getPrevious() instanceof FrontControllerException) {
                    throw $e->getPrevious();
                }

                throw $e;
            }

        } catch (FrontControllerException $fe) {
            throw $fe;
        } catch (\Exception $e) {
            throw new RendererException(
                sprintf('%s in %s.', $e->getMessage(), $filename),
                RendererException::RENDERING_ERROR,
                $e
            );
        }

        return $render;
    }