Load view template with arguments

@param string $slug
@param string $name
@param array $args
1259
public static function view($slug, $name = '', array $args = []){
        $class_name = get_called_class();
        /** @var Controller $instance */
        $instance = $class_name::get_instance();
        $instance->lazy_scripts();
        $instance->load_template($slug, $name, $args);
    }
834946
public function loadView($viewName, $pData = NULL, $asString = false) {
		if(!URequest::isAjax() && $this->_getAuthController()->_displayInfoAsString()){
			$this->view->setVar("_userInfo",$this->_getAuthController()->info());
		}
		return parent::loadView ($viewName,$pData,$asString);
	}
205653
public function callFunction($name, Template $template = null, $arguments = [])
    {
        $callable = $this->getFunction($name);

        if (\is_array($callable) &&
            isset($callable[0]) &&
            $callable[0] instanceof ExtensionInterface
        ) {
            $callable[0]->template = $template;
        }

        return $callable(...$arguments);
    }
927184
protected function render($template, $args = array())
    {
        if (!is_null($this->renderTemplateSuffix)
            && !preg_match('/\.' . $this->renderTemplateSuffix . '$/', $template)
        ) {
            $template .= '.' . $this->renderTemplateSuffix;
        }
        $this->app->render($template, $args);
    }
935512
private function exec( $controller_name, $args )
	{
		// Process controller
		$compo = explode( '@', $controller_name );

		if ( count( $compo ) <= 1 ) {

			throw new Exception( sprintf( 'Controller action must be defined in %s.', $controller_name ) );

		}

		// Get controller
		require_once(  $this->controllers_path . $compo[0] . '.php' );
		$classname = sprintf( $this->namespace . '\Controllers\%s', $compo[0]);
		$controller = new $classname( $this->view );

		if ( !method_exists( $controller, $compo[1] ) ) {

			throw new Exception( sprintf( 'Controller action "%s" not found in %s.', $compo[1], $compo[0] ) );

		}

		return call_user_func_array( [ $controller, $compo[1] ], $args );
	}
1222628
public static function get_template_part( $slug, $name = null, array $vars = [] ) {
		WP_View_Controller\Helper\get_template_part( $slug, $name, $vars );
	}
101041
public function handler($name, Args $args)
    {
        if (
            !$this->checkLevel($args->get('level')) ||
            !$this->checkSource($args->get('source'))
        ) {
            return;
        }

        switch ($name) {
            /*
            case ':log:':
                $this->log($args);
                break; // case 'log'

            */
            case ':onAddHandler:':
                $args->set('message', sprintf(
                    "Adding handler %s, %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    ),
                    $args->get('added', false)
                        ? "successfully" :
                        "failed (duplicate handler)"
                ));
                break; // case ':onAddHandler:'

            case ':onEventStart:':
                $args->set('message', sprintf(
                    "{ '%s' (%s), args [%s]",
                    $args->get('name'),
                    $args->get('uid'),
                    implode(', ', array_keys($args->get()))
                ));
                break; // case ':onEventStart:'

            case ':onHandlerFound:':
                $args->set('message', sprintf(
                    "Handler %s found",
                    $this->handlerToString($args->get('handler'))
                ));
                break; // case ':onAddHandler:'

            case ':onEventEnd:':
                $args->set('message', sprintf(
                    "} '%s' (%s), args [%s]",
                    $args->get('name'),
                    $args->get('uid'),
                    implode(', ', array_keys($args->get()))
                ));
                break; // case ':onEventEnd:'

            case ':onDropHandlers:':
                $args->set('message', sprintf(
                    "Dropping handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'

            case ':onDisableHandler:':
                $args->set('message', sprintf(
                    "Disabling handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'

            case ':onEnableHandler:':
                $args->set('message', sprintf(
                    "Enabling handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'
        }
        $this->log($args);
    }
1091938
public static function register( $slug, $name ) {
		if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.7', '<' ) ) {
			self::old_register( $slug, $name );
		} else {
			self::$templates[ $slug ] = $name;
			add_filter( 'theme_page_templates', [ __CLASS__, 'register_template' ] );
		}
	}
613536
public static function form($slug, $name = '', array $attributes = []){
        $class_name = get_called_class();
        /** @var AjaxBaseForm $instance */
        $instance = $class_name::get_instance();
        $instance->form_open($attributes);
        $args = $instance->form_arguments();
        $instance->load_template($slug, $name, $args);
        $instance->form_close();
    }
1336614
public function addArgument($name, Argument $arg = null) {
        if (isset($this->configOpts[$name]) || isset($this->configArgs[$name])) {
            throw new ConfigException('option/argument already set: ' . $name);
        }

        if (is_null($arg)) {
            $arg = new Argument();
        }

        $this->configArgs[$name] = $arg;
        return $arg;
    }
141242
public function load_template($slug, $name = '', array $args = []){
        $base_path = $slug.'.php';
        $original_path = $slug.( !empty($name) ? '-'.$name : '' ).'.php';
        $found_path = '';
        foreach( [$original_path, $base_path] as $file ){
            foreach( [get_stylesheet_directory(), get_template_directory()] as $dir ){
                $path = $dir.'/'.ltrim($file, '\\');
                if( file_exists($path) ){
                    $found_path = $path;
                    break 2;
                }
            }
        }
        if( $found_path ){
            // Path found. Let's locate template.
            global $post, $posts, $wp_query;
            if( !empty($args) ){
                extract($args);
            }
            include $found_path;
        }
    }
1226867
public function render($name, array $args = array())
    {
        if ($this->has($name)) {
            $callback = $this->widgets[$name];

            return $this->executeCallback($callback, $args);
        }

        return '';
    }
478486
public function load($name)
    {
        if (!isset($this->templates[$name])) {
            $this->templates[$name] = $this->loadFile($name);
        }

        return $this->templates[$name];
    }
1221093
public function get( $slug, $name = '' )
	{
		$template = UtilityFacade::startWith( 'templates/', $slug );
		$templates = ["$template.php"];
		if( !empty( $name )) {
			$fileName = basename( $template );
			$filePath = UtilityFacade::trimRight( $template, $fileName );
			array_unshift( $templates, sprintf( '%s/%s.php', $filePath.$name, $fileName ));
		}
		$templates = array_unique( apply_filters( "castor/templates/$slug", $templates, $name ));
		$template = locate_template( $templates );
		if( empty( $template )) {
			if( file_exists( "$slug.php" )) {
				return "$slug.php";
			}
			LogFacade::debug( "$slug not found." );
		}
		return $template;
	}
1082571
public static function section($name, $args, $child) {
		//Convenient under the hood change to
		//make things easier
		$args["sectionPath"] = $args["path"];
		unset($args["path"]);

		//Add to sections
		Router::$sections[] = [$name, $args, $child, Router::$context];
	}
287260
public function template($name, array $params = []): ResponseInterface
    {
        if (\is_array($name)) {
            $params = $name;
            $name = null;
        }

        if ($name === null) {
            $handler = $this->app->handler();
            if ($handler instanceof \Closure) {
                throw new \LogicException('Con not build the template from closure handler!');
            }

            $name = \ltrim($handler['app'] . '/' . $handler['controller'] . '/' . $handler['action'], '/');
        } elseif (!\is_string($name)) {
            throw new \InvalidArgumentException('Template name not found!');
        }

        $response = $this->response();

        return $this->app->render($response, $name, $params);
    }
51163
function load($name): string {
    if (!isset($this->views[$name])) {
      $cacheKey = [__CLASS__, $name];
      $viewRenderer = $this->viewRenderer;

      /** @var \yii\caching\Cache $cache */
      $cache = $viewRenderer->cache;
      if ($viewRenderer->enableCaching && $cache->exists($cacheKey))
        $output = $cache->get($cacheKey);
      else {
        $path = FileHelper::localize($this->findViewFile($name));
        if (!is_file($path)) throw new InvalidCallException("The view file '$path' does not exist.");

        $output = @file_get_contents($path);
        if ($viewRenderer->enableCaching) $cache->set($cacheKey, $output, $viewRenderer->cachingDuration);
      }

      $this->views[$name] = $output;
    }

    return $this->views[$name];
  }