@param Template $template
@param array    $options

@return array
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;
    }
1041231
protected function parse(array $options)
    {
        $templates = [
            'page' => []
        ];

        foreach ($options as $slug => $properties) {
            // 1 - $slug is int -> meaning it's only for pages
            // and $properties is the slug name.
            if (is_int($slug)) {
                $templates['page'][$properties] = $this->formatName($properties);
            } else {
                // 2 - (associative array) $slug is a string and we're dealing with $properties.
                // 2.1 - $properties is a string only, so the template is only available to page.
                if (is_string($properties)) {
                    $templates['page'][$slug] = $properties;
                }

                // 2.2 - $properties is an array.
                if (is_array($properties) && ! empty($properties)) {
                    // 2.2.1 - $properties has only one value, meaning it's a display name
                    //and only available to page.
                    if (1 === count($properties) && is_string($properties[0])) {
                        $templates['page'][$slug] = $properties[0];
                    }

                    // 2.2.2 - $properties has 2 values
                    if (2 === count($properties)) {
                        // 2.2.2.1 - Loop through the second one (cast it as array in case of).
                        $post_types = (array) $properties[1];

                        foreach ($post_types as $post_type) {
                            $post_type = trim($post_type);

                            // Verify if $post_type exists. If not, add it with a default value.
                            if (! isset($templates[$post_type])) {
                                $templates[$post_type] = [];
                            }

                            // The is a $post_type in the $templates.
                            // Basically, add the templates to each one of them.
                            $templates[$post_type][$slug] = is_string($properties[0])
                                ? trim($properties[0])
                                : $this->formatName($slug);
                        }
                    }
                }
            }
        }

        return $templates;
    }
1143332
public function render(array $options = array())
    {
        if (!empty($options['providers'])) {
            $outputProviders = array();
            foreach ($options['providers'] as $provider) {
                $outputProviders[] = $this->getProvider($provider);
            }
        } else {
            $outputProviders = $this->getDefaultProviders();
        }

        unset($options['providers']);

        $renderedProviders = array();
        foreach ($outputProviders as $label => $provider) {
            $provider->setTemplateEngine($this->templateEngine);
            $provider->setTemplateName($options['template']);
            $provider->setLabel($label);
            $renderedProviders[$label] = $provider->render($options);
        }

        return $renderedProviders;
    }
729472
protected function render($template, $parameters)
    {
        $option = array(
            'debug' => true,
            'cache' => false,
            'strict_variables' => true,
            'autoescape' => false,
        );

        $self = $this;
        $twig = new \Twig_Environment(new \Twig_Loader_Filesystem($this->SBOskeletonDirs), $option);

        $twig->addFunction(new \Twig_SimpleFunction(
            'renderFile',
            function ($template, $target, $subParameters = []) use ($self,$parameters) {
                $self->renderFile($template, $target, array_merge($parameters, $subParameters));

                return '';
            },
            $option
        ));

        $twig->addFunction(new \Twig_SimpleFunction(
            'method_exists',
            function ($object, $methodeName) {
                return method_exists($object, $methodeName);
            },
            $option
        ));

        return $twig->render($template, $parameters);
    }
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();
	}
1218960
protected function parseTemplate($template, array $vars = array())
    {
        if (strpos($template, '{') === false) {
            return $template;
        }

        if (preg_match_all('@\{\$([A-Za-z0-9_]+)\}@i', $template, $matches)) {
            foreach ($matches[1] as $varName) {
                $template = str_replace('{$' . $varName . '}', $vars[$varName], $template);
            }
        }

        return $template;
    }
1186721
protected static function fetchTemplate( $template, $parameters = array() )
    {
        $tpl = eZTemplate::factory();
        $existingPramas = array();

        foreach( $parameters as $name => $value )
        {
            if ( $tpl->hasVariable( $name ) )
                $existingPramas[$name] = $tpl->variable( $name );

            $tpl->setVariable( $name, $value );
        }

        $result = $tpl->fetch( $template );

        foreach( $parameters as $name => $value )
        {
            if ( isset( $existingPramas[$name] ) )
                $tpl->setVariable( $name, $existingPramas[$name] );
            else
                $tpl->unsetVariable( $name );
        }

        return $result;
    }
262287
public function precompile($template, $options = [])
    {
        if ($this->isRuntime) {
            throw new \BadMethodCallException("Cannot precompile templates using runtime");
        }

        $this->v8->template = $template;
        $this->v8->options = $options;
        return $this->v8->executeString(
            'jsHb.precompile(phpHb.template, phpHb.options)',
            __CLASS__ . '::' . __METHOD__ . '()'
        );
    }
999031
protected function getZonesByTemplate($template)
    {
        $zones = $this->templates[$template]['zones'];

        foreach ($zones as $key => $zone) {
            $temp = array_map([$this, 'jsString'], $zone['restricted_types']);
            $zones[$key]['restricted_types'] = '['.implode(',', $temp).']';

            $zones[$key]['restricted_types'] = json_encode($zone['restricted_types']);
        }

        return $zones;
    }
155583
private function getOptions(array $options, $defaultTemplate)
    {
        if (!array_key_exists('template', $options)) {
            $options['template'] = $defaultTemplate;
        }

        if (!array_key_exists('route', $options)) {
            $options['route'] = null;
        }

        if (!array_key_exists('route_params', $options)) {
            $options['route_params'] = [];
        }

        return $options;
    }
359027
public function renderTemplate($pathToTemplateFile, array $options = [])
    {
        if (!file_exists($pathToTemplateFile)) {
            throw new InvalidArgumentException(
                "Can't find template file: {$pathToTemplateFile}"
            );
        }

        $renderName = 'from_file';
        $this->twigLoader->setTemplate($renderName, file_get_contents($pathToTemplateFile));

        try {
            $return = $this->twig->load($renderName)->render($options);
        } catch (\Exception $e) {
            throw new Exception($e->getMessage(), $e->getCode(), $e);
        }

        return $return;
    }
1313107
public static function update_template($template) {

        $params = self::validate_parameters(self::update_template_parameters(), array('template' => $template));
        $params = $params['template'];
        $template = api::read_template($params['id']);
        self::validate_context($template->get_context());

        $params = (object) $params;

        return api::update_template($params);
    }
264408
function(templateName, options) {
        var template = this.templates[templateName];
        if (!template) {
            throw new Error('Unknown template: ' + templateName);
        }

        if (typeof template === 'function') {
            var templateResult = template(options);
            return typeof templateResult === 'string' ? templateResult.trim() : templateResult;
        } else if (template.render) {
            return template.render(options).trim();
        } else {
            return template.toString().trim();
        }
    }
264880
public function scheduleBlastFromTemplate($template, $list, $schedule_time, $options = [ ]) {
        $data = $options;
        $data['copy_template'] = $template;
        $data['list'] = $list;
        $data['schedule_time'] = $schedule_time;
        return $this->apiPost('blast', $data);
    }
676661
protected function render(array $options, array $templateParams = [])
    {
        $template = isset($options['template']) ? $options['template'] : $this->getDefaultTemplate();

        return $this->templating->render($template, array_merge($options, $templateParams));
    }
1325769
public function getTagOptions($tag, $options)
    {
        return isset($this->tagOptions[$tag]) ? $this->tagOptions[$tag] : array();
    }
397053
private function findTemplate($template)
    {
        $logicalName = (string) $template;

        if (isset($this->cache[$logicalName])) {
            return $this->cache[$logicalName];
        }

        $template = $this->templateNameParser->parse($template);
        $file = $this->templateLocator->locate($template);

        return $this->cache[$logicalName] = $file;
    }