获得指定模板填充后的内容

@param templateDir 模板所在目录，绝对路径
@param templateFileName 模板名称
@param context 上下文（变量值的容器）
@param charset 字符集
@return 模板和内容匹配后的内容
437639
public static String getContent(String templateDir, String templateFileName, VelocityContext context, String charset) {
		// 初始化模板引擎
		final VelocityEngine ve = newEngine(templateDir, charset);

		return getContent(ve, templateFileName, context);
	}
986190
@Override
    public String getTemplateURI(String controllerName, String templateName) {
        TupleStringKey key = new TupleStringKey(controllerName, templateName);
        String uri = templateURICache.get(key);
        if (uri == null) {
            uri = super.getTemplateURI(controllerName, templateName);
            String prevuri=templateURICache.putIfAbsent(key, uri);
            if (prevuri != null) {
                return prevuri;
            }
        }
        return uri;
    }
458271
public static StringTemplate stringTemplate(String template, Object... args) {
        return stringTemplate(createTemplate(template), ImmutableList.copyOf(args));
    }
36307
function getTemplate(template) {
  var ret;

  store.roots.some(function(r) {
    var filepath = path.join(r, template);
    if (file.exists(filepath)) {
      ret = filepath;
      return true;
    }
  });

  return ret;
}
561111
public static StringTemplate stringTemplate(Template template, Object... args) {
        return stringTemplate(template, ImmutableList.copyOf(args));
    }
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;
  }
844497
function Template (filename, context) {
    // Save the context for reuse in sub-templates
    this.context = context || {}
    this.context.include = this.render.bind(this)
    this.context.forEach = forEach

    // Save the filename for the initial render
    this.filename = filename

    // Create a cache so we only read files once
    this.cache = {}
}
1113408
public T getTemplateFromCache(String filename) {

        LRUCache.CacheEntry<String, T> cachedTemplate = cache.get(filename);

        // this is to avoid null pointer exception in case of the layout composite template
        if (cachedTemplate == null) {
            return null;
        }

        return cachedTemplate.compiled;
    }
640499
public static void write(final String templateFilename, final Map<String, Object> data,
            final Writer writer) {
        Template tmpl = null;
        try {
            /*-
             * note that we don't need to cache templates by ourselves since getTemplate() does that internally already
             */
            tmpl = conf.getTemplate(templateFilename);
        } catch (FileNotFoundException e1) {
            String errMsg = "FileNotFoundException: template file '" + templateFilename
                    + "' not found";
            log.error("{}: {}", errMsg, e1.getMessage());
            throw new AwsMockException(errMsg, e1);
        } catch (IOException e) {
            String errMsg = "IOException: failed to getTemplate (filename is " + templateFilename
                    + ")";
            log.error("{}: {}", errMsg, e.getMessage());
            throw new AwsMockException(errMsg, e);
        }

        try {
            tmpl.process(data, writer);
        } catch (TemplateException e) {
            StringBuilder dataDescription = new StringBuilder();

            if (null != data) {
                for (Map.Entry<String, Object> entry : data.entrySet()) {
                    dataDescription.append(entry.getKey() + " - " + entry.getValue()).append('\n');
                }
            }
            String errMsg = "TemplateException: failed to process template '" + templateFilename
                    + "', with data: "
                    + dataDescription.toString()
                    + " The probable cause could be un-matching of key-values for that template. ";
            log.error("{}: {}", errMsg, e.getMessage());
            throw new AwsMockException(errMsg, e);
        } catch (IOException e) {
            String errMsg = "IOException: failed to process template and write to writer. ";
            log.error("{}: {}", errMsg, e.getMessage());
            throw new AwsMockException(errMsg, e);
        }

    }
727230
private ThymeLeafTemplateImplementation getTemplateByFile(File templateFile) {
        try {
            return getTemplateByURL(templateFile.toURI().toURL());
        } catch (MalformedURLException e) {  //NOSONAR
            // Ignored.
        }
        return null;
    }
1195039
public static QueryTemplate create(String name, Iterable<String> values, Charset charset) {
    return create(name, values, charset, CollectionFormat.EXPLODED);
  }
775708
public EvaluatedTemplate evaluateTemplate(String template, EvaluationContext context) {
        return evaluateTemplate(template, context, false);
    }
1215103
public static String readTemplate(String root, String template) throws IOException {
		if (root == null) {
			return readTemplate(template);
		}
		String settingsFile = root + "/" + Defaults.TemplateDir + "/" + template + Defaults.JsonFileExtension;
		return readFileFromClasspath(settingsFile);
	}
844015
synchronized public static void init(String templateDir, String charset) {
		Velocity.init(_newInitedProp(templateDir, charset));
		Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_CACHE, true); // 使用缓存

		isInited = true; // 标记完成初始化
	}
69742
protected InputStream getTemplateAsStream(TestContext context) {
        Resource resource;
        if (templateResource != null) {
            resource = templateResource;
        } else {
            resource = FileUtils.getFileResource(template, context);
        }

        String templateYml;
        try {
            templateYml = context.replaceDynamicContentInString(FileUtils.readToString(resource));
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to read template resource", e);
        }
        return new ByteArrayInputStream(templateYml.getBytes());
    }
1279180
private String loadTemplateFile(String templateName) {
		String name = templateName.replace('.', '/') + ".java";
		InputStream in = SpoonMojoGenerate.class.getClassLoader().getResourceAsStream(name);
		String packageName = templateName.substring(0, templateName.lastIndexOf('.'));
		String fileName = templateName.substring(templateName.lastIndexOf('.') + 1) + ".java";
		try {
			return TemplateLoader.loadToTmpFolder(in, packageName, fileName)
					.getAbsolutePath();
		} catch (IOException e) {
			LogWrapper.warn(spoon, String.format("Template %s cannot be loaded.", templateName), e);
			return null;
		}
	}
511810
public GroovyActionBuilder template(Resource scriptTemplate, Charset charset) {
		try {
            action.setScriptTemplate(FileUtils.readToString(scriptTemplate, charset));
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to read script template file", e);
        }
		return this;
	}