Renders an item

@param array $options
@param string $templateData
546277
protected function renderItem($options, $templateData)
    {
        //apply editable if not set 'editable' params or set and not false
        $apply = !empty($options['name']) && (!isset($options['editable']) || $options['editable'] !== false);

        if ($apply) {
            //ensure $options['editable'] is array
            if (!isset($options['editable'])) $options['editable'] = array();

            //merge options with defaults: url, params, etc.
            $options['editable'] = CMap::mergeArray($this->_data, $options['editable']);

            //options to be passed into EditableField (constructed from $options['editable'])
            $widgetOptions = array(
                'model' => $this->data,
                'attribute' => $options['name']
            );

            //if value in detailview options provided, set text directly (as value here means text)
            if (isset($options['value']) && $options['value'] !== null) {
                $widgetOptions['text'] = $templateData['{value}'];
                $widgetOptions['encode'] = false;
            }

            $widgetOptions = CMap::mergeArray($widgetOptions, $options['editable']);

            $widget = $this->controller->createWidget('WhEditableField', $widgetOptions);

            //'apply' maybe changed during init of widget (e.g. if related model has unsafe attribute)
            if ($widget->apply) {
                ob_start();
                $widget->run();
                $templateData['{value}'] = ob_get_clean();
            }
        }

        parent::renderItem($options, $templateData);
    }
135501
public function renderTwigBlock($resource, $blockName, array $options = [])
    {
        if (null !== $this->environment) {
            /* @var \Twig_Template $template */
            $template = $this->environment->loadTemplate($resource);

            return $template->renderBlock($blockName, $options);
        }

        return '';
    }
273709
public function render($template, $data = [], array $options = []) {
		$defaults = ['context' => []];
		$options += $defaults;

		$this->_context = $options['context'] + $this->_context;
		$this->_data = (array) $data + $this->_vars;
		$this->_options = $options;
		$template__ = $template;
		unset($options, $template, $defaults, $data);

		if ($this->_config['extract']) {
			extract($this->_data, EXTR_OVERWRITE);
		} elseif ($this->_view) {
			extract((array) $this->_view->outputFilters, EXTR_OVERWRITE);
		}

		ob_start();
		include $template__;
		return ob_get_clean();
	}
656399
protected function _renderMenu(ItemInterface $item, array $options)
    {
        if (!$item->hasChildren() ||
            $options['depth'] === 0 ||
            !$item->getDisplayChildren()
        ) {
            return '';
        }

        $templater = $this->templater();

        $newTemplates =
            (array)$item->getExtra('templates') +
            (array)$options['templates'];
        if ($newTemplates) {
            $templater->push();
            $templater->add($newTemplates);
        }
        $options['defaultTemplates'] = $templater->getConfig();
        unset($options['templates']);

        $templateVars =
            (array)$item->getExtra('templateVars') +
            (array)$options['templateVars'];
        if (empty($templateVars)) {
            $templateVars = null;
        }
        $options['defaultTemplateVars'] = $templateVars;
        unset($options['templateVars']);

        $rendered = (string)$templater->format('menu', [
            'attrs' => $this->_formatAttributes($item->getChildrenAttributes(), $item),
            'templateVars' => $templateVars,
            'items' => $this->_renderChildren($item, $options)
        ]);

        if ($newTemplates) {
            $templater->pop();
        }

        return $rendered;
    }
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));
    }
942997
public function setUp(Template $template, array $options)
    {
        $this->template = $template;

        $this->assets = array();
        $methods = array(
            'getExternalStylesheets',
            'getExternalJavascripts',
            'getInternalStylesheets',
            'getInternalJavascripts',
        );
        foreach ($methods as $method) {
            $this->assets[$method] = $this->initAssets($method, $template, $options);
        }
    }
701316
protected function render($templates, array $data = array())
    {
        $content = $this->view->render($templates, $data);
        $response = new Response();
        $response->setContent($content);

        return $response;
    }
789179
public function render($options = array())
    {
        $template = $options['template'];
        $data = $options['data'];

        if (file_exists(($file = $this->templatePath.DIRECTORY_SEPARATOR.$template.'.tpl.php'))) {
            $template = file_get_contents($file);
        }
        else {
            Console::writeInfo('template '.$file.' was not found...');
        }

        return $this->renderTpl($template, $data);
    }
238423
public static function select(Collection $data, $selected = 0, $options = [], $htmlOptions = [])
    {
        if (empty($options['valueColumn']))
            $options['valueColumn'] = Model::PK;
        if (empty($options['titleColumn']))
            $options['titleColumn'] = 'title';
        if (is_array($selected))
            $selected = $selected[$options['valueColumn']];
        if ($selected instanceof Model) {
            $selected = $selected->{$options['valueColumn']};
        }
        if (empty($options['disabled']))
            $options['disabled'] = [];

        if ($options instanceof Std) {
            $options = $options->getData();
        }

        $htmlOptionsText = [];
        foreach ($htmlOptions as $key => $value) {
            if (is_numeric($key)) {
                $htmlOptionsText[] = $value;
            } else {
                $htmlOptionsText[] = $key . '="' . $value . '"';
            }
        }
        $htmlOptionsText = implode(' ', $htmlOptionsText);

        $html = '<select ' . $htmlOptionsText . '>' . "\n";
        if (
            isset($options['null']) && $options['null']
            &&
            $data->first()[$options['valueColumn']] !== 0 && $data->first()[$options['titleColumn']] !== '---'
        ) {
            $data->prepend([$options['valueColumn'] => 0, $options['titleColumn'] => '---']);
        }
        foreach ($data as $item) {
            $html .=
                '<option
                    value="' . $item[$options['valueColumn']] . '"' .
                ($item[$options['valueColumn']] == $selected ? ' selected="selected"' : '') .
                (in_array($item[$options['valueColumn']], $options['disabled']) ? ' disabled="disabled"' : '') .
                '>' .
                (
                    in_array('tree', $options) && isset($options['treeLevelColumn']) && isset($item[$options['treeLevelColumn']])
                        ? str_repeat(self::TREE_LEVEL_SYMBOL, (int)$item[$options['treeLevelColumn']])
                        : ''
                ) . ' ' .
                $item[$options['titleColumn']] .
                '</option>' . "\n";
        }
        $html .= '</select>';
        return $html;
    }
1118693
public function render($template, $data = [], array $options = []) {
		$defaults = ['context' => []];
		$options += $defaults;

		$context = [];
		$this->_context = $options['context'] + $this->_context;

		foreach (array_keys($this->_context) as $key) {
			$context[$key] = $this->__get($key);
		}
		$data = array_merge($this->_toString($context), $this->_toString($data));
		return Text::insert($template, $data, $options);
	}
284696
public function setTemplateData(array $templateData)
    {
        if (!isset($this->templateData)) {
            $this->templateData = [];
        }

        $this->templateData = array_merge($this->templateData, $templateData);

        return $this;
    }
929474
public function render($data = array(), $params = array())
    {
        if ($this->controller->getTemplate() !== null) {
            foreach ($this->controller->filters as $filter) {
                $this->twig->addFilter($filter);
            }
            $this->twig->addGlobal('params', $params);
            $key = "twig" . microtime(true);
//            Debugbar::timer($key, $this->controller->getTemplate());
            $template = $this->twig->load($this->controller->getTemplate());
            $data = $template->render($this->getData($data));
//            Debugbar::stopTimer($key);
        }
        return $data;
    }
372008
public static function renderAs($data, string $content_type, array $options = []) {
		// clena up output buffer
		\Helper\Ob::cleanAll();
		Application::set('flag.global.__content_type', $content_type);
		Application::set('flag.global.__skip_layout', 1);
		header("Content-type: " . $content_type);
		if (!empty($options['output_file_name'])) {
			header('Content-Disposition: attachment; filename=' . $options['output_file_name']);
		}
		$options['extension'] = ($options['extension'] ?? '');
		switch ($content_type . $options['extension']) {
			case 'application/json':
				echo json_encode($data);
				break;
			case 'application/xml':
				if (is_array($data)) {
					echo array2xml($data);
				} else {
					echo $data;
				}
				break;
			case 'text/html':
				\Helper\Ob::start();
				require(Application::get(['application', 'path_full']) . 'Layout/blank.html');
				echo str_replace([
					'<!-- [numbers: document title] -->',
					'<!-- [numbers: document body] -->'
				], [
					\Layout::renderDocumentTitle(),
					$data
				], \Helper\Ob::clean());
				break;
			case 'text/htmlemail':
				\Helper\Ob::start();
				require(Application::get(['application', 'path_full']) . 'Layout/' . \Application::get('application.layout.email') . '.html');
				echo str_replace([
					'<!-- [numbers: document title] -->',
					'<!-- [numbers: document body] -->'
				], [
					'<title>' . ($options['title'] ?? '') . '</title>',
					$data
				], \Helper\Ob::clean());
				break;
			case 'text/htmlplain':
			default:
				echo $data;
		}
		exit;
	}
741662
public function renderTemplate($templateId, $request)
    {
        $query = ($request instanceof Request) ? $request->id : $request;
        return $this->sendRequest('GET', '/templates/' . $templateId . '/render?request_id=' . $query);
    }
966833
public function serialize(Template $template, array $options = [])
    {
        $serialized = [
            'id' => $template->getUuid(),
            'name' => $template->getName(),
            'type' => $this->serializer->serialize($template->getType()),
            'title' => $template->getTitle(),
            'content' => $template->getContent(),
            'lang' => $template->getLang(),
            'localized' => $this->serializeLocalized($template),
        ];

        return $serialized;
    }
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;
    }
1225860
public function render($options = array()) {
		
		$result = $this->instance->render($options["pattern"], $options["data"]);
		// This error handler catches files that didn't render using any of the loaders.
		// The most common scenario is when a file's contents get passed to and through `Twig_Loader_String` and
		// outputs the raw Twig file contents like `@atoms/buttons/button.twig`.
		// @todo Remove this once `Twig_Loader_String` is removed.
		if (strpos($result, "@") === 0) {
			echo "Twig file not found: " . $result . "\n";
			exit(1);
		} else {
			return $result;
		}
		
	}