Set the template name, assign params array and return rendered output in one method.
Call this function in routes and controllers.

@param string $tpl
@param array $params
@return string
189948
public function render($tpl, $params = [])
    {
        $this->setTemplate($tpl);
        $this->params = (object) $params;
        return $this->retrieve();
    }
582041
public function render($tpl, array $vars = array(), array $cookies = array())
    {
        Logger::log('Start render response');
        $vars = ResponseHelper::setDebugHeaders($vars);
        $output = $this->dump($tpl, $vars);

        return $this->output($output, 'text/html', $cookies);
    }
171503
function (tpl) {
      var tree = []
      var openTag
      var tag
      var name
      var paramStr
      var node
      var closeTag
      var usedExtends = 0

      for (openTag = this.findTag('', tpl); openTag; openTag = this.findTag('', tpl)) {
        if (openTag.index) {
          tree = tree.concat(this.parseText(tpl.slice(0, openTag.index)))
        }
        tpl = tpl.slice((openTag.index + openTag[0].length))
        tag = openTag[1].match(/^\s*(\w+)(.*)$/)
        if (tag) {
          // Function?!
          name = tag[1]
          paramStr = (tag.length > 2) ? tag[2].replace(/^\s+|\s+$/g, '') : ''
          if (name in this.buildInFunctions) {
            var buildIn = this.buildInFunctions[name]
            var params = ('parseParams' in buildIn ? buildIn.parseParams.bind(this) : this.parseParams.bind(this))(paramStr)
            if (buildIn.type === 'block') {
              // Remove new line after block open tag (like in Smarty)
              tpl = tpl.replace(/^\n/, '')
              closeTag = this.findCloseTag('/' + name, name + ' +[^}]*', tpl)
              var functionTree = buildIn.parse.call(this, params, tpl.slice(0, closeTag.index))
              if (functionTree) {
                // Some functions return false like {php} and {function}
                tree = tree.concat(functionTree)
              }
              tpl = tpl.slice(closeTag.index + closeTag[0].length)
            } else {
              if (name === 'extends') {
                // Anything before {extends} should be stripped.
                tree.splice(0, tree.length)
              }
              tree = tree.concat(buildIn.parse.call(this, params))
              if (name === 'extends') {
                usedExtends = tree.length
              }
            }
            tpl = tpl.replace(/^\n/, '')
          } else if (name in this.runTimePlugins) {
            // Possible it is function name. give it a priority before plugin.
            tree = tree.concat(this.parsePluginFunc(name, this.parseParams(paramStr)))
          } else if (name in this.plugins) {
            var plugin = this.plugins[name]
            if (plugin.type === 'block') {
              closeTag = this.findCloseTag('/' + name, name + ' +[^}]*', tpl)
              tree = tree.concat(this.parsePluginBlock(name, this.parseParams(paramStr), tpl.slice(0, closeTag.index)))
              tpl = tpl.slice(closeTag.index + closeTag[0].length)
            } else if (plugin.type === 'function') {
              tree = tree.concat(this.parsePluginFunc(name, this.parseParams(paramStr)))
            }
            if (name === 'append' || name === 'assign' || name === 'capture' || name === 'eval' || name === 'include') {
              tpl = tpl.replace(/^\n/, '')
            }
          } else {
            // Variable.
            node = this.buildInFunctions.expression.parse.call(this, openTag[1])
            tree.push(node)
          }
        } else {
          // Variable.
          node = this.buildInFunctions.expression.parse.call(this, openTag[1])
          if (node.expression.type === 'build-in' && node.expression.name === 'operator' && node.expression.op === '=') {
            tpl = tpl.replace(/^\n/, '')
          }
          tree.push(node)
        }
      }
      if (tpl) {
        tree = tree.concat(this.parseText(tpl))
      }
      tree.usedExtends = usedExtends
      return tree
    }
1043367
public function render(array $options, $name, $selected = array(), array $attrs = array(), $tpl = false)
    {
        if (is_array($selected)) {
            $last = Arr::last($selected);
            $selectedVal = Arr::in($last, $selected) ? $last : null;
            list($options, $selected) = $this->_checkSelected($options, $selectedVal);
        }

        if (is_string($selected)) {
            list($options, $selected) = $this->_checkSelected($options, $selected);
        }

        return parent::render($options, $name, $selected, $attrs, $tpl);
    }
853007
public function render($tpl, array $data = [], $status = null)
    {
        $vitex = Vitex::getInstance();
        $vitex->render($tpl, $data, $status);
    }
1287730
protected function _setTpl($tpl)
    {
        $this->_tpl = $tpl;

        if ($tpl === true) {
            $this->_tpl = self::TPL_WRAP;
        }

        if ($tpl === false) {
            $this->_tpl = self::TPL_DEFAULT;
        }
    }
992665
protected function renderOutput(string $template, array $vars = [])
    {
        $tpl = $this->template . '.'. $template;

        if (view()->exists($tpl)) {
            return view($tpl, $vars)->render();
        }

        abort(404, "View named $tpl not exists.");
    }
174584
public function getOutput($tpl = null)
    {
        $output = $this->fetch($tpl);
        if ($this->isError($output)) {
            $text = $this->configList[self::ERROR_TEXT];
            return $text; //TODO: escape this output?
        } else {
            return $output;
        }
    }
666979
public function display($tpl, $outputtype = '', $trusted = true)
    {
        $previousTpl = $this->_templateName;
        $this->_templateName = $tpl;
        $this->recursiveTpl[] = $tpl;
        $md = $this->getTemplate($tpl, $outputtype, $trusted);

        $fct = 'template_'.$md;
        $fct($this);
        array_pop($this->recursiveTpl);
        $this->_templateName = $previousTpl;
    }
629800
protected function render($tpl)
    {
        $body = new View(
            $tpl,
            get_object_vars($this) + $this->app->locals,
            array('dir' => $this->app->views)
        );

        $this->app->render($this->_tpl_layout, array('body' => $body->render()) + get_object_vars($this));
    }
828290
function layout($tpl = null) {
        //        $template = explode('::', $as);
        //        if (count($template) > 1) {
        //            $namespace = Arr::get($template, 0);
        //            if (substr_count($namespace, '-') && substr_count(Arr::get($template, 1), '.')) {
        //                $package   = explode('.', Arr::get($template, 1), 3);
        //                $end       = Arr::get($package, 2, "");
        //                if ($end) {
        //                    $end = '.' . $end;
        //                }
        //                $package = Arr::get($package, 1) . '.' . Arr::get($package, 0) . $end;
        //
        //                $as = $namespace . '::' . trim($package, '.');
        //                dd($as );
        //            }
        //        }
        if (true === $tpl) {
            $this->layout = \Route::currentRouteName();
        } elseif (null !== $tpl) {
            $this->layout = $tpl;
        }
        //        dd($this->layout);

        return $this;
    }
667727
protected function tpl($template, array $values)
    {
        if((!isset($values['id']) || !$values['id']) && isset($values['name'])) {
            $values['id'] = sprintf('input-%s', $values['name']);
        }

        $buffer = $template;
        foreach($values as $key => $val) {
            $buffer = str_replace('{{' . $key . '}}', $val, $buffer);
        }
        
        // Cleaning up the remaining placeholders.
        $buffer = preg_replace('%\{\{[^}]*\}\}%', '', $buffer);
        
        return $buffer;
    }
583908
public function display($tpl, $data = array())
    {
        if ($this->isRending) {
            throw new RenderException('Display is called.');
        }

        $this->assign($data);

        echo $this->render($tpl, $data);

        return true;
    }
970119
protected function render(string $template, array $parameters): string
    {
        $twig = new Environment(
            new FilesystemLoader([$this->skeletonDir]),
            [
                'debug' => true,
                'cache' => false,
                'strict_variables' => true,
                'autoescape' => false,
            ]
        );

        return $twig->render($template, $parameters);
    }
764188
protected function render(Response $response, $template, array $params = [])
    {
        return $this->container['twig']->render($response, $template, $params);
    }
706488
public function template($view, array $param = [], $return = false)
    {
        $this->setTwigEnvironment();
        $path = $this->getPath(Inflector::toDirectorySeparator($view), true);

        /*
         | We will check if tpl is holding the object of
         | twig, then we will set twig template
         | environment
         */
        if (is_object(static::$twigEnvironment)/* && is_file($path)*/) {
            $this->setTwigTemplateInstance($view);
        }
        /*
        | We will check is twig template instance exists
        | then we will render twig template with parameters
        */
        if (is_object(static::$twigEnvironment) && is_object($this->get('twig_template'))) {
            return ($return) ?
                $this->get('twig_template')->render($param) :
                $this->get('twig_template')->display($param);
        }

        return $this;
    }
412834
protected function _fetchTemplate($params = array())
	{
		// Check
		$directory = isset($params['directory']) ? $params['directory'] : PATH_CORE . '/templates';

		$template = isset($params['template']) ? preg_replace('/[^A-Z0-9_\.-]/i', '', $params['template']) : 'system';
		$file     = isset($params['file'])     ? preg_replace('/[^A-Z0-9_\.-]/i', '', $params['file'])     : 'index.php';

		if (!file_exists($directory . DS . $template . DS . $file))
		{
			$directory = PATH_CORE . '/templates';
			$template  = 'system';
			$params['baseurl'] = str_replace('/app', '/core', $params['baseurl']);
		}

		// Load the language file for the template
		$lang = \App::get('language');
		$lang->load('tpl_' . $template, PATH_APP . DS . 'bootstrap' . DS . \App::get('client')->name, null, false, true) ||
		$lang->load('tpl_' . $template, $directory . DS . $template, null, false, true);

		// Assign the variables
		$this->template = $template;
		//$this->path     = (isset($params['path']) ? $params['path'] : rtrim(\Request::root(true), '/')) . '/templates/' . $template;
		//$this->baseurl  = rtrim(\Request::root(true), '/');
		$this->baseurl  = isset($params['baseurl']) ? $params['baseurl'] : rtrim(\Request::root(true), '/');
		$this->params   = isset($params['params'])  ? $params['params']  : new Registry;

		// Load
		$this->_template = $this->_loadTemplate($directory . DS . $template, $file);

		return $this;
	}