Renders a template $template into $outputFile with the given templates directory $templates and input $data.

@param Input $input
@param string $outputFile
@param string $template
@param string $templates
@param array $data
332885
protected function renderTemplate($input, $outputFile, $template, $templates, $data = [])
    {
        $paths = [$templates];

        if ($templates = $input->getOption('templates')) {
            $paths []= $templates;
        }

        $paths = array_filter($paths);

        $loader = new Twig_Loader_Filesystem($paths);
        $twig = new Twig_Environment($loader);


        $template = $twig->loadTemplate($template);

        $dataOption = $input->getOption('data');

        if (file_exists($dataOption)) {
            $dataOption = file_get_contents($dataOption);
        }

        $dataOption = json_decode(stripcslashes($dataOption), true);

        if (!is_array($dataOption)) {
            $dataOption = [];
        }

        $data = array_merge($data, $dataOption);

        @mkdir(dirname($outputFile), 0755, true);
        file_put_contents($outputFile, $template->render($data));
    }
908193
public function template($template, $data = Array()){
        \Template::with($template, $data);
        \View::serve();
    }
858336
public function render(string $template, array $data = []) : string
    {
        try {
            return $this->renderer->render($template, $data);
        } catch (Twig_Error_Loader $e) {
            throw new TemplateNotFoundException("Template '$template' not found by Twig renderer",
                null, $e);
        }
    }
838976
public function renderTemplate($templatePath = null, $data = [])
    {
        $templateData = $this->readTemplate($templatePath);
        if($data === null) {
            throw new Exception("template(): expects parameter 2 to be array, null given");
        }
        foreach($data as $key => $val) {
            if(is_array($val)) {
                $findStart = strpos($templateData, '{{'.$key.':}}');
                if($findStart !== false) {
                    $findEnd = strpos($templateData, '{{:'.$key.'}}');
                    if($findEnd !== false) {
                        $len = 5 + strlen($key);
                        $substr = substr($templateData, $findStart, ($findEnd - $findStart));
                        $substr = substr($substr, $len);
                        $loopstr = []; #fixed-for: Uncaught Error: [] operator not supported for strings $loopstr[]
                        foreach($val as $k => $v) {
                            $temp = $substr;
                            if(is_array($v)) {
                                //$temp = strtr($temp, $v); {{}} not replaced
                                foreach($v as $ks => $vs) {
                                    $temp = str_replace('{{'.$ks.'}}', $vs, $temp);
                                }
                            }
                            else {
                                $temp = str_replace('{{'.$key.'}}', $v, $temp);
                            }
                            $loopstr[] = $temp;
                        }
                        $loopstr = implode("\n", $loopstr);
                        $templateData = str_replace('{{'.$key.':}}'.$substr.'{{:'.$key.'}}', $loopstr, $templateData);
                    }
                    else {
                        throw new Exception('Error in template : loop has not closed properely');
                        exit;
                    }
                }
            }
            else {
                $templateData = str_replace('{{'.$key.'}}', $val, $templateData);
            }
        }
        return $templateData;
    }
356909
public function renderString(string $template, array $data = [])
    {
        try {
            return $this->loadFromString($template)->render($data);
        } catch (SyntaxError $e) {
            if ($this->exceptionHandler) {
                $e->setTemplateContent($template);

                return $this->renderSyntaxError($e);
            } else {
                throw $e;
            }
        }
    }
113149
public static function nativeRender($template = '', $data = [])
    {
        $templatesPath = realpath(__DIR__ . '/../templates');
        $templates     = new \League\Plates\Engine($templatesPath);

        return $templates->render($template, $data);
    }
542647
public static function render($template, $data = [])
    {
        // @var \Illuminate\View\Factory $factory
        $factory = self::instance()->view();

        // @var \Illuminate\Contracts\View\View $view
        $view = $factory->make($template, $data);

        return $view->render();
    }
687963
public function render(View $template, array $data = array())
    {
        if (! empty($this->data)) { // @codeCoverageIgnore
            $data = array_merge($this->data, $data); // @codeCoverageIgnore
        } // @codeCoverageIgnore

        // Path
        $path = $template->getFullPath();

        // Declare all data vars local if possible
        foreach ($data as $name => $value) {
            ${$name} = $value;
        }

        // Require and stop with OB.
        ob_start();

        require $path;

        return ob_get_clean();
    }
1280854
public function render($templates, array $data = array())
    {
        $templates = (array) $templates;

        foreach ($templates as $template) {
            if (!is_readable($template) || !is_file($template)) {
                throw new \Shade\Exception('Template file "'.$template.'" does not exists');
            }
            $content = str_replace(array_keys($data), $data, file_get_contents($template));
            $data[$this->layoutContentPlaceholder] = $content;
        }

        return $content;
    }
387454
def parse_template(input_filename, output_filename=''):
    
    data = load_input()
    with open(input_filename, 'rb') as file:
        template = file.read().decode("utf-8")
    
    # Check if 'input' in data
    if not 'input' in data:
        raise ValueError("Could not find 'input' in data")
    
    # Parse template
    for field in data['input']:
        subs = ["filename", "value"] if isinstance(data['input'][field], dict) and "filename" in data['input'][field] and "value" in data['input'][field] else [""]
        for sub in subs:
            displayed_field = field + (":" if sub else "") + sub
            regex = re.compile("@([^@]*)@" + displayed_field + '@([^@]*)@')
            for prefix, postfix in set(regex.findall(template)):
                if sub == "value":
                    text = open(data['input'][field][sub], 'rb').read().decode('utf-8')
                elif sub:
                    text = data['input'][field][sub]
                else:
                    text = data['input'][field]
                rep = "\n".join([prefix + v + postfix for v in text.splitlines()])
                template = template.replace("@{0}@{1}@{2}@".format(prefix, displayed_field, postfix), rep)
    
    if output_filename == '':
        output_filename=input_filename
    
    # Ensure directory of resulting file exists
    try:
        os.makedirs(os.path.dirname(output_filename))
    except OSError as e:
        pass

    # Write file
    with open(output_filename, 'wb') as file:
        file.write(template.encode("utf-8"))
340865
final public function output($templates = null, array $options = array())
    {
        if (empty($templates)) {
            $templates = $this->templates;
        }

        $this->prepareDataOutput();
        $this->prepareOutput($templates, $options);
        $this->response->outputHtml($this->renderOutput($templates), $options);
    }
486427
public function renderPage(string $template, array $data = []): string
    {
        $this->thisShouldMakeItUniqueCodeCollabTemplateHtmlVariables = $data;

        /** @noinspection PhpUnusedLocalVariableInspection */
        $content = $this->render($template, $data);

        try {
            ob_start();

            /** @noinspection PhpIncludeInspection */
            require $this->thisShouldMakeItUniqueCodeCollabTemplateHtmlBasePage;
        } finally {
            $output = ob_get_clean();
        }

        return $output;
    }
859876
public function renderTemplate($filename, $data, $return = false)
    {
        $templateOutput = $this->parseTemplate($filename, $data);

        if ($return)
        {
            return $templateOutput;
        }

        echo $templateOutput;
        return $return;
    }
1233288
public function render(string $template, array $data = []): string
    {
        // we store the current state of the template variables
        // so that we have isolated cases on multiple calls to render()
        $backupVariables = $this->thisShouldMakeItUniqueCodeCollabTemplateHtmlVariables;

        if (!empty($data)) {
            $this->thisShouldMakeItUniqueCodeCollabTemplateHtmlVariables = $data;
        }

        try {
            ob_start();

            /** @noinspection PhpIncludeInspection */
            require $template;
        } finally {
            $output = ob_get_clean();
        }

        $this->thisShouldMakeItUniqueCodeCollabTemplateHtmlVariables = $backupVariables;

        return $output;
    }
699150
public function render(ResponseInterface $response, $template, array $data = array())
    {
        $this->view->loadFile($this->templatesPath . DIRECTORY_SEPARATOR . $template);
        $this->renderWithData($response, $data);
        return $response;
    }
182903
public function useTwigTemplate($template, array $data = array())
	{
		$html = $this->renderer->render($template, $data);
		$this->setHtml($html);
		return $this;
	}
885123
public function render($template, $vars = [], $directOutput = false)
    {
        $context = $this->_context;

        if (DIRECTORY_SEPARATOR === '\\' && strpos($template, '\\') !== false) {
            $template = str_replace('\\', '/', $template);
        }

        if (strpos($template, '/') === false) {
            $template = dirname(end($context->templates)) . '/' . $template;
        }

        $template = $template[0] === '@' ? $this->alias->resolve($template) : $template;

        if (isset($this->_files[$template])) {
            list($file, $extension) = $this->_files[$template];
        } else {
            $file = null;
            $extension = null;
            foreach ($this->_engines as $extension => $engine) {
                if (is_file($file = $template . $extension)) {
                    if (PHP_EOL !== "\n") {
                        $realPath = strtr(realpath($file), '\\', '/');
                        if ($file !== $realPath) {
                            trigger_error("File name ($realPath) case mismatch for $file", E_USER_ERROR);
                        }
                    }

                    break;
                }
            }

            if (!$file) {
                throw new FileNotFoundException([
                    '`:template` with `:extensions` extension file was not found',
                    'template' => $template,
                    'extensions' => implode(', or ', array_keys($this->_engines))
                ]);
            }

            $this->_files[$template] = [$file, $extension];
        }

        if (!isset($this->_resolved[$extension])) {
            $engine = $this->_resolved[$extension] = $this->_di->getShared($this->_engines[$extension]);
        } else {
            $engine = $this->_resolved[$extension];
        }

        if (isset($vars['renderer'])) {
            throw new MisuseException('variable `renderer` is reserved for renderer');
        }
        $vars['renderer'] = $this;

        if (isset($vars['di'])) {
            throw new MisuseException('variable `di` is reserved for renderer');
        }
        $vars['di'] = $this->_di;

        $context->templates[] = $template;

        $eventArguments = ['file' => $file, 'vars' => $vars];
        $this->eventsManager->fireEvent('renderer:beforeRender', $this, $eventArguments);

        if ($directOutput) {
            $engine->render($file, $vars);
            $content = null;
        } else {
            ob_start();
            ob_implicit_flush(false);
            $engine->render($file, $vars);
            $content = ob_get_clean();
        }

        $this->eventsManager->fireEvent('renderer:afterRender', $this, $eventArguments);

        array_pop($context->templates);

        return $content;
    }