Ensure post template requests get routed to our main front controller instead of some random file.

@since  1.0.0

@param  string $template_path Path of template to load.
@return string Path of template to load.
490413
public function post_template_routing($template_path)
    {
        $routes_file = \get_template_directory() . '/public/routes.php';
        
        if (\is_child_theme()) {
            $routes_file = \locate_template('public/routes.php');
        }

        if ('' !== $routes_file) {
            return $routes_file;
        }
        
        return $template_path;
    }
918025
function loadTemplate( $templateFile )
    {
        // this function will load the requested template ($file includes full or relative pathname)
        // the code for the template will be modified to make it name safe, and then stored in
        // an array for later use
        // The id of the template will be returned for the user to operate on it later
        if ( !file_exists( $templateFile ) )
        {
            return -1;
        }

        $code = implode( '', file( $templateFile ) );
        if ( !strlen( $code ) )
        {
            return;
        }

        $code = trim( $code );
        if ( substr( $code, 0, 5 ) == '<?php' )
        {
            $code = substr( $code, 5 );
        }
        if ( substr( $code, -2 ) == '?>' )
        {
            $code = substr( $code, 0, strlen( $code ) - 2 );
        }
        if ( isset( $this->ez['numTemplates'] ) )
        {
            $newNum = $this->ez['numTemplates'];
            $this->ez['numTemplates']++;
        }
        else
        {
            $newNum = 0;
            $this->ez['numTemplates'] = 1;
            $this->ez['templates'] = array();
        }

        $this->ez['templates'][$newNum]['code'] = $code;

        return $newNum;
    }
596134
function display($template_file) {
        $template = $this->twig->load($template_file);
        echo $template->render($this->twig_vars);
    }
219686
public function getTemplateLibrary($template_id)
    {
        $url = 'https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get?access_token=ACCESS_TOKEN';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, ['id' => $template_id], true);
    }
1078229
public function fetch($templateFile,$var) {
        $templateFile=substr($templateFile,strlen(THEME_PATH));
        $var['_think_template_path']=$templateFile;
        exit(json_encode($var));	
    }
184914
public function templatePath($path = null)
    {
        deprecationWarning(
            'View::templatePath() is deprecated. ' .
            'Use getTemplatePath()/setTemplatePath() instead.'
        );

        if ($path === null) {
            return $this->templatePath;
        }

        $this->templatePath = $path;
    }
1171906
def render_without_request(template_name, template_path=None, **template_vars):
    
    if template_path:
        env = Environment(loader=FileSystemLoader([os.path.join(template_path)]))
    else:
        env = ENV
    template = env.get_template(template_name)
    return template.render(**template_vars)
664314
function (path, next) {
      var t$ = this;
      // Check Cache
      if ($.inArray(path, t$.cache) > -1) {
        return next && next()
      }

      // Use jQuery Ajax to fetch the template file
      var _templateLoader = $.get(path)
        .success(function (result) {
          if ($.inArray(path, t$.cache) === -1) {
            t$.cache.push(path);
            // On success, Add templates to DOM (assumes file only has template definitions)
            $('body').append(result);
          }
        })
        .error(function (result) {
          alert('Error Loading Templates -- TODO: Better Error Handling');
        });

      _templateLoader.complete(function () {
        // Publish an event that indicates when a template is done loading
        $(host).trigger('TEMPLATE_LOADED', [path]);
        next && next();
      });
    }
801113
protected function loadTemplate( $path, array $vars = [] ) {
		try {
			return \Pressbooks\Utility\template( $path, $vars );
		} catch ( \Exception $e ) {
			if ( WP_DEBUG ) {
				return "File not found: {$path}";
			} else {
				return '';
			}
		}
	}
1230591
public function parse( $template_file )
    {
        if ( file_exists( $template_file ) ) {
            $content = file_get_contents($template_file);

            foreach ( $this->vars as $key => $value ) {
                if ( is_array( $value ) ) {
                    $content = $this->parsePair($key, $value, $content);
                } else {
                    $content = $this->parseSingle($key, (string) $value, $content);
                }
            }

            return $content;
        } else {
            exit( '<h1>Template error</h1>' );
        }
    }
1181043
public function load($data_folder = '')
  {
    $this->templates_path = $data_folder . '/templates';

    $files = $this->read_dir($this->templates_path);

    $pattern = '/^(\w+).phtml$/';

    foreach($files as $file) {
      if (preg_match($pattern, $file, $match)) {
        $this->templates[$match[1]] = $file;
      }
    }
  }
1275718
protected function findTwigFile($path, $template = null)
    {
        if ($template == null) {
            $template = $this->template;
        }

        return '::' . self::TWIG_TEMPLATE_PATH . '/' . $template . '/' . $path;
    }
425284
public function setTemplateDir($path = VIEW) {
		$old = $this->_sv_template_dir;
		$this->_sv_template_dir  = $path;

		return $old;
	}
647325
protected function parse_template() {

        if (empty($this->params)) {
            $this->params = array();
            if (isset($_SERVER['PATH_INFO']) && !empty($_SERVER['PATH_INFO'])) {
                $path = explode('/', $_SERVER['PATH_INFO']);
                $parts = explode('/', $this->get_template());
                for ($i = 0; $i < count($parts); $i++) {
                    if ((substr($parts[$i], 0, 1) == '{') && (substr($parts[$i], -1) == '}')) {
                        $value = '';
                        if ($i < count($path)) {
                            $value = $path[$i];
                        }
                        $this->params[substr($parts[$i], 1, -1)] = $value;
                    }
                }
            }
        }

        return $this->params;

    }
606178
String createTemplateServerRequest(String servletPath,String templateName) {
        String pathInfo = servletPath.substring(servletPath.indexOf("/",TEMPLATE_LOAD_PROTOCOL.length()));
        if (templateName != null) {            
            pathInfo = pathInfo + templateName;
        }
        return pathInfo;
    }
170885
protected function getTemplateMatches($template, $path)
    {
        $template = '~^' . preg_replace('~\<(\d+)\>~', '(?<p_$1>.+?)', $template) . '$~i';
        if (!preg_match($template, $path, $m)) {
            return false;
        } else {
            $matches = [];
            foreach ($m as $key => $value) {
                if (substr($key, 0, 2) == 'p_') {
                    $matches[substr($key, 2)] = $value;
                }
            }
            return $matches;
        }
    }
85080
public function resolveTemplate($request_string)
    {
        $this->debug(sprintf('resolveTemplate: Resolving %s.', $request_string));

        $template = false;

        $this->buildTemplateIndex();

        // First break off any GET vars appended to the URL, splitting
        // either on '?' or '.html'.
        if (false !== strpos($request_string, '?')) {
            $request_string = substr($request_string, 0, strpos($request_string, '?'));
        } elseif (false !== strpos($request_string, '.html')) {
            $request_string = substr($request_string, 0, strpos($request_string, '.html') + 5);
        }

        // Append .html if not already there
        if ('.html' !== substr($request_string, -5)) {
            $request_string .= '.html';
        }

        $this->debug(sprintf('resolveTemplate: Matching relative template path %s.', $request_string));

        // Search the index for a matching template
        if (array_key_exists($request_string, $this->templateIndex)) {
            $template = $this->templateIndex[$request_string];

            $this->debug(sprintf(
                'resolveTemplate: Resolved Template %s (%s).',
                $template->getRenderName(),
                $template->getFilename()
            ));
        }

        return($template);
    }