public function render($nameOrModel, array $variables = [])
    {
        $__module = null;

        if ($nameOrModel instanceof ViewModelInterface) {
            $model       = $nameOrModel;
            $nameOrModel = $model->getTemplate();
            $__module    = $model->getModule();
            $variables   = array_merge($model->getVariables(), $variables);
            unset($model);
        } elseif (! is_string($nameOrModel)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid render source provided; must be a string or instance '
                . 'of "%s", "%s" received.',
                ViewModelInterface::CLASS,
                is_object($nameOrModel) ? get_class($nameOrModel)
                                        : gettype($nameOrModel)
            ));
        }

        extract($variables);
        $__old = $this->setVariables($variables);
        unset($variables);

        try {
            ob_start();
            include $this->getResolver()->resolve($nameOrModel, $__module);
            $__return = ob_get_clean();
        } catch (Error $e) {
            ob_end_clean();
            throw $e;
        } catch (Exception $e) {
            ob_end_clean();
            throw $e;
        }
        $this->setVariables($__old);

        return $__return;
    }
public function render($nameOrModel, array $variables = [])
    {
        $__module = null;

        if ($nameOrModel instanceof ViewModelInterface) {
            $model       = $nameOrModel;
            $nameOrModel = $model->getTemplate();
            $__module    = $model->getModule();
            $variables   = array_merge($model->getVariables(), $variables);
            unset($model);
        } elseif (! is_string($nameOrModel)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid render source provided; must be a string or instance '
                . 'of "%s", "%s" received.',
                ViewModelInterface::CLASS,
                is_object($nameOrModel) ? get_class($nameOrModel)
                                        : gettype($nameOrModel)
            ));
        }

        extract($variables);
        $__old = $this->setVariables($variables);
        unset($variables);

        try {
            ob_start();
            include $this->getResolver()->resolve($nameOrModel, $__module);
            $__return = ob_get_clean();
        } catch (Error $e) {
            ob_end_clean();
            throw $e;
        } catch (Exception $e) {
            ob_end_clean();
            throw $e;
        }
        $this->setVariables($__old);

        return $__return;
    }
public function render ( $ nameOrModel , array $ variables = [ ] ) { $ __module = null ; if ( $ nameOrModel instanceof ViewModelInterface ) { $ model = $ nameOrModel ; $ nameOrModel = $ model -> getTemplate ( ) ; $ __module = $ model -> getModule ( ) ; $ variables = array_merge ( $ model -> getVariables ( ) , $ variables ) ; unset ( $ model ) ; } elseif ( ! is_string ( $ nameOrModel ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid render source provided; must be a string or instance ' . 'of "%s", "%s" received.' , ViewModelInterface :: CLASS , is_object ( $ nameOrModel ) ? get_class ( $ nameOrModel ) : gettype ( $ nameOrModel ) ) ) ; } extract ( $ variables ) ; $ __old = $ this -> setVariables ( $ variables ) ; unset ( $ variables ) ; try { ob_start ( ) ; include $ this -> getResolver ( ) -> resolve ( $ nameOrModel , $ __module ) ; $ __return = ob_get_clean ( ) ; } catch ( Error $ e ) { ob_end_clean ( ) ; throw $ e ; } catch ( Exception $ e ) { ob_end_clean ( ) ; throw $ e ; } $ this -> setVariables ( $ __old ) ; return $ __return ; }
Renders the view model or template.

@param string|Es\Mvc\ViewModelInterface $nameOrModel The name of template
or instance of
view model
@param array                            $variables   Optional; the variables
uses to render

@throws \InvalidArgumentException If invalid type of render source
specified

@return string The result of rendering
Renders the view model or template .