Determine a FreeMarker TemplateLoader for the given path.

@param templateLoaderPath the path to load templates from
@return an appropriate TemplateLoader
@throws IOException if an I/O error has occurred
@see freemarker.cache.FileTemplateLoader
546285
protected TemplateLoader getTemplateLoaderForPath(String templateLoaderPath) throws IOException {
        if (templateLoaderPath.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) {
            String basePackagePath = templateLoaderPath.substring(ResourceUtils.CLASSPATH_URL_PREFIX.length());
            if (log.isDebugEnabled()) {
                log.debug("Template loader path [" + templateLoaderPath +
                        "] resolved to class path [" + basePackagePath + "]");
            }
            return new ClassTemplateLoader(environment.getClassLoader(), basePackagePath);
        } else if (templateLoaderPath.startsWith(ResourceUtils.FILE_URL_PREFIX)) {
            File file = new File(templateLoaderPath.substring(ResourceUtils.FILE_URL_PREFIX.length()));
            if (log.isDebugEnabled()) {
                log.debug("Template loader path [" + templateLoaderPath +
                        "] resolved to file path [" + file.getAbsolutePath() + "]");
            }
            return new FileTemplateLoader(file);
        } else {
            File file = new File(environment.getBasePath(), templateLoaderPath);
            if (log.isDebugEnabled()) {
                log.debug("Template loader path [" + templateLoaderPath +
                        "] resolved to file path [" + file.getAbsolutePath() + "]");
            }
            return new FileTemplateLoader(file);
        }
    }
533771
public static TemplatePathInfo forPage(@NotNull Page page, @NotNull TemplatePathInfo @NotNull... templates) {
    if (page == null || templates == null) {
      return null;
    }
    String templatePath = page.getProperties().get(NameConstants.PN_TEMPLATE, String.class);
    return forTemplatePath(templatePath, templates);
  }
1030433
public static boolean isProvider(String templatePath) {

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(templatePath)) {
            return false;
        }
        templatePath = templatePath.trim();
        return templatePath.startsWith(DYNAMIC_TEMPLATE_LEGACY_PREFIX)
            || templatePath.startsWith(DYNAMIC_TEMPLATE_PREFIX);
    }
707774
private File getTemplateFile(String filename) throws IOException {
        File templateFile=null;
        final String resource = TEMPLATE_RESOURCES_PATH + "/" + filename;
        InputStream is = Setup.class.getClassLoader().getResourceAsStream(resource);
        if (null == is) {
            throw new RuntimeException("Unable to load required template: " + resource);
        }
        templateFile = File.createTempFile("temp", filename);
        templateFile.deleteOnExit();
        try {
            return copyToNativeLineEndings(is, templateFile);
        } finally {
            is.close();
        }
    }
272168
private TemplateImpl load(String path, ParserRuleContext errCtx) {

  	path = Paths.resolvePath(currentEnvironment.path, path);
  	
    try {
      return (TemplateImpl) engine.load(path);
    }
    catch (IOException | ParseException e) {
      throw new ExecutionException("error importing " + path, e, getLocation(errCtx));
    }
  }
577597
public Template getTemplate (String path, String encoding)
        throws Exception
    {
        Object siteId = get("__siteid__");
        if (siteId != null) {
            path = siteId + ":" + path;
        }
        if (encoding == null) {
            return RuntimeSingleton.getRuntimeServices().getTemplate(path);
        } else {
            return RuntimeSingleton.getRuntimeServices().getTemplate(path, encoding);
        }
    }
213443
public Template getTemplate(String name) throws IOException, ParseException {
        return getTemplate(name, null, null, null);
    }
572071
public static String compile(String path, String templateName, Map<String, Object> input) {
		try {
			Template template = getConfig(path).getTemplate(templateName);
			StringWriter writer = new StringWriter();
			template.process(input, writer);
			return writer.toString();
		} catch (Exception e) {
			JK.throww(e);
			return null;
		}

	}
852170
protected String findClasspathFile(final String path) throws IOException {
        if (path == null){
            return null;
        }
        final File file = new File(path);
        if (file.exists()){
            return file.getAbsolutePath();
        }
        return createTmpFile(path).getAbsolutePath();
    }
1102221
public static TemplatePathInfo forTemplatePath(@NotNull String templatePath, @NotNull TemplatePathInfo @NotNull... templates) {
    if (templatePath == null || templates == null || templates.length == 0) {
      return null;
    }
    for (TemplatePathInfo template : templates) {
      if (StringUtils.equals(template.getTemplatePath(), templatePath)) {
        return template;
      }
    }
    return null;
  }
197207
private function getFluidStandaloneViewWithTemplate($templatePath = '')
    {
        $standaloneView = GeneralUtility::makeInstance(StandaloneView::class);
        $standaloneView->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templatePath));

        return $standaloneView;
    }
436607
public Template parseTeaTemplate(String templateName) throws IOException {

        if (templateName == null) {
            return null;
        }

        preserveParseTree(templateName);
        compile(templateName);
        CompilationUnit unit = getCompilationUnit(templateName, null);
        if (unit == null) {
            return null;
        }

        return unit.getParseTree();
    }
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;
    }
225631
@Override
	public Template getTemplate(String resource) {
		try {
			return FreemarkerTemplate.wrap(this.cfg.getTemplate(resource));
		} catch(IOException e) {
			throw new IORuntimeException(e);
		}catch (Exception e) {
			throw new TemplateException(e);
		}
	}
484077
def generate_file_template_load(path):
        
        path = os.path.expanduser(os.path.abspath(
                path
        ))

        def read_file():
            """
            Read file from path and return file contents
            :return:
            """
            with open(path) as template:
                return template.read()

        return read_file
304233
private static InputStream getResourceAsStream(String path) throws IOException {
    if (StringUtils.isEmpty(path)) {
      return null;
    }

    // first try to load as file
    File file = new File(path);
    if (file.exists() && file.isFile()) {
      return new FileInputStream(file);
    }

    // if not a file fallback to classloader resource
    return CertificateLoader.class.getResourceAsStream(path);
  }
161381
public @Nonnull Optional<ResourceLoader> getLoaderForBasePath(@Nonnull String basePath) {
        ArgumentUtils.requireNonNull("basePath", basePath);
        Optional<ResourceLoader> resourceLoader = getSupportingLoader(basePath);
        return resourceLoader.map(rl -> rl.forBase(basePath));
    }