本文整理了Java中freemarker.core.Environment.rootBasedToAbsoluteTemplateName()
方法的一些代码示例,展示了Environment.rootBasedToAbsoluteTemplateName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.rootBasedToAbsoluteTemplateName()
方法的具体详情如下:
包路径:freemarker.core.Environment
类名称:Environment
方法名:rootBasedToAbsoluteTemplateName
[英]Converts a root based name (a name that's either relative to the root, or is absolute), which are typically used by the API (such as for Configuration#getTemplate(String)), to an absolute name, which can be safely passed to and such, as it won't be misinterpreted to be relative to the directory of the template. For example, "foo/bar.ftl" is converted to "/foo/bar.ftl", while "/foo/bar" or "foo://bar/baz" remains as is, as they are already absolute names (see TemplateNameFormat for more about the format of names).
You only need this if the template name will be passed to , , .get_optional_template(name) or a similar construct in a template, otherwise using non-absolute root based names is fine.
[中]将API通常使用的基于根的名称(相对于根的名称或绝对名称)(例如用于配置#getTemplate(String)),转换为绝对名称,该名称可以安全地传递给,并且不会被误解为相对于模板的目录。例如,“foo/bar.ftl”转换为“/foo/bar.ftl”,而“/foo/bar”或foo://bar/baz“保持原样,因为它们已经是绝对名称(有关名称格式的更多信息,请参阅TemplateNameFormat)。
仅当模板名称将传递给时,才需要此选项。获取可选的模板(名称)或模板中的类似构造,否则使用非绝对的基于根的名称就可以了。
代码示例来源:origin: org.freemarker/freemarker
/**
* @param basePath Maybe {@code null}
*/
private String resolvePath(String basePath) throws TemplateModelException {
try {
return env.rootBasedToAbsoluteTemplateName(env.toFullTemplateName(basePath, pathToResolve));
} catch (MalformedTemplateNameException e) {
throw new _TemplateModelException(e,
"Can't resolve ", new _DelayedJQuote(pathToResolve),
"to absolute template name using base ", new _DelayedJQuote(basePath),
"; see cause exception");
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
/**
* @param basePath Maybe {@code null}
*/
private String resolvePath(String basePath) throws TemplateModelException {
try {
return env.rootBasedToAbsoluteTemplateName(env.toFullTemplateName(basePath, pathToResolve));
} catch (MalformedTemplateNameException e) {
throw new _TemplateModelException(e,
"Can't resolve ", new _DelayedJQuote(pathToResolve),
"to absolute template name using base ", new _DelayedJQuote(basePath),
"; see cause exception");
}
}
代码示例来源:origin: org.freemarker/freemarker-gae
/**
* @param basePath Maybe {@code null}
*/
private String resolvePath(String basePath) throws TemplateModelException {
try {
return env.rootBasedToAbsoluteTemplateName(env.toFullTemplateName(basePath, pathToResolve));
} catch (MalformedTemplateNameException e) {
throw new _TemplateModelException(e,
"Can't resolve ", new _DelayedJQuote(pathToResolve),
"to absolute template name using base ", new _DelayedJQuote(basePath),
"; see cause exception");
}
}
内容来源于网络,如有侵权,请联系作者删除!