本文整理了Java中freemarker.core.Environment.toFullTemplateName()
方法的一些代码示例,展示了Environment.toFullTemplateName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.toFullTemplateName()
方法的具体详情如下:
包路径:freemarker.core.Environment
类名称:Environment
方法名:toFullTemplateName
[英]Resolves a reference to a template (like the one used in #include or #import), assuming a base name. This gives a root based, even if non-normalized and possibly non-absolute (but then relative to the root) template name, that could be used for Configuration#getTemplate(String). This is mostly used when a template refers to another template.
If you need to guarantee that the result is also an absolute path, then apply #rootBasedToAbsoluteTemplateName(String) on it.
[中]使用基名称解析对模板的引用(如#include或#import中使用的模板)。这提供了一个基于根的模板名称,即使是非规范化的、可能是非绝对的(但相对于根)模板名称,也可以用于配置#getTemplate(字符串)。这主要用于模板引用另一个模板时。
如果需要保证结果也是绝对路径,则对其应用#rootBasedToAbsoluteTemplateName(字符串)。
代码示例来源:origin: org.freemarker/freemarker
/**
* @deprecated Use {@link Environment#toFullTemplateName(String, String)} instead, as that can throw
* {@link MalformedTemplateNameException}, and is on a more logical place anyway.
*
* @throws IllegalArgumentException
* If the {@code baseName} or {@code targetName} is malformed according the {@link TemplateNameFormat}
* in use.
*/
@Deprecated
public static String getFullTemplatePath(Environment env, String baseName, String targetName) {
try {
return env.toFullTemplateName(baseName, targetName);
} catch (MalformedTemplateNameException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
代码示例来源:origin: org.freemarker/freemarker
static Template getTemplate(String systemId) throws IOException {
Environment env = Environment.getCurrentEnvironment();
String encoding = env.getTemplate().getEncoding();
if (encoding == null) {
encoding = env.getConfiguration().getEncoding(env.getLocale());
}
String templatePath = env.getTemplate().getName();
int lastSlash = templatePath.lastIndexOf('/');
templatePath = lastSlash == -1 ? "" : templatePath.substring(0, lastSlash + 1);
systemId = env.toFullTemplateName(templatePath, systemId);
Template raw = env.getConfiguration().getTemplate(systemId, env.getLocale(), encoding, false);
return raw;
}
代码示例来源: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.freemarker/freemarker
@Override
TemplateElement[] accept(Environment env) throws TemplateException, IOException {
final String importedTemplateName = importedTemplateNameExp.evalAndCoerceToPlainText(env);
final String fullImportedTemplateName;
try {
fullImportedTemplateName = env.toFullTemplateName(getTemplate().getName(), importedTemplateName);
} catch (MalformedTemplateNameException e) {
throw new _MiscTemplateException(e, env,
"Malformed template name ", new _DelayedJQuote(e.getTemplateName()), ":\n",
e.getMalformednessDescription());
}
try {
env.importLib(fullImportedTemplateName, targetNsVarName);
} catch (IOException e) {
throw new _MiscTemplateException(e, env,
"Template importing failed (for parameter value ",
new _DelayedJQuote(importedTemplateName),
"):\n", new _DelayedGetMessage(e));
}
return null;
}
代码示例来源:origin: org.freemarker/freemarker
final String fullIncludedTemplateName;
try {
fullIncludedTemplateName = env.toFullTemplateName(getTemplate().getName(), includedTemplateName);
} catch (MalformedTemplateNameException e) {
throw new _MiscTemplateException(e, env,
代码示例来源:origin: org.freemarker/freemarker
absTemplateName = env.toFullTemplateName(env.getCurrentTemplate().getName(), templateName);
} catch (MalformedTemplateNameException e) {
throw new _TemplateModelException(
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
/**
* @deprecated Use {@link Environment#toFullTemplateName(String, String)} instead, as that can throw
* {@link MalformedTemplateNameException}, and is on a more logical place anyway.
*
* @throws IllegalArgumentException
* If the {@code baseName} or {@code targetName} is malformed according the {@link TemplateNameFormat}
* in use.
*/
@Deprecated
public static String getFullTemplatePath(Environment env, String baseName, String targetName) {
try {
return env.toFullTemplateName(baseName, targetName);
} catch (MalformedTemplateNameException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
代码示例来源:origin: org.freemarker/freemarker-gae
/**
* @deprecated Use {@link Environment#toFullTemplateName(String, String)} instead, as that can throw
* {@link MalformedTemplateNameException}, and is on a more logical place anyway.
*
* @throws IllegalArgumentException
* If the {@code baseName} or {@code targetName} is malformed according the {@link TemplateNameFormat}
* in use.
*/
@Deprecated
public static String getFullTemplatePath(Environment env, String baseName, String targetName) {
try {
return env.toFullTemplateName(baseName, targetName);
} catch (MalformedTemplateNameException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
代码示例来源:origin: org.freemarker/freemarker-gae
static Template getTemplate(String systemId) throws IOException {
Environment env = Environment.getCurrentEnvironment();
String encoding = env.getTemplate().getEncoding();
if (encoding == null) {
encoding = env.getConfiguration().getEncoding(env.getLocale());
}
String templatePath = env.getTemplate().getName();
int lastSlash = templatePath.lastIndexOf('/');
templatePath = lastSlash == -1 ? "" : templatePath.substring(0, lastSlash + 1);
systemId = env.toFullTemplateName(templatePath, systemId);
Template raw = env.getConfiguration().getTemplate(systemId, env.getLocale(), encoding, false);
return raw;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
static Template getTemplate(String systemId) throws IOException {
Environment env = Environment.getCurrentEnvironment();
String encoding = env.getTemplate().getEncoding();
if (encoding == null) {
encoding = env.getConfiguration().getEncoding(env.getLocale());
}
String templatePath = env.getTemplate().getName();
int lastSlash = templatePath.lastIndexOf('/');
templatePath = lastSlash == -1 ? "" : templatePath.substring(0, lastSlash + 1);
systemId = env.toFullTemplateName(templatePath, systemId);
Template raw = env.getConfiguration().getTemplate(systemId, env.getLocale(), encoding, false);
return raw;
}
代码示例来源: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");
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
@Override
TemplateElement[] accept(Environment env) throws TemplateException, IOException {
final String importedTemplateName = importedTemplateNameExp.evalAndCoerceToPlainText(env);
final String fullImportedTemplateName;
try {
fullImportedTemplateName = env.toFullTemplateName(getTemplate().getName(), importedTemplateName);
} catch (MalformedTemplateNameException e) {
throw new _MiscTemplateException(e, env,
"Malformed template name ", new _DelayedJQuote(e.getTemplateName()), ":\n",
e.getMalformednessDescription());
}
try {
env.importLib(fullImportedTemplateName, targetNsVarName);
} catch (IOException e) {
throw new _MiscTemplateException(e, env,
"Template importing failed (for parameter value ",
new _DelayedJQuote(importedTemplateName),
"):\n", new _DelayedGetMessage(e));
}
return null;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
absTemplateName = env.toFullTemplateName(env.getCurrentTemplate().getName(), templateName);
} catch (MalformedTemplateNameException e) {
throw new _TemplateModelException(
代码示例来源:origin: org.freemarker/freemarker-gae
final String fullIncludedTemplateName;
try {
fullIncludedTemplateName = env.toFullTemplateName(getTemplate().getName(), includedTemplateName);
} catch (MalformedTemplateNameException e) {
throw new _MiscTemplateException(e, env,
代码示例来源:origin: org.freemarker/freemarker-gae
@Override
TemplateElement[] accept(Environment env) throws TemplateException, IOException {
final String importedTemplateName = importedTemplateNameExp.evalAndCoerceToPlainText(env);
final String fullImportedTemplateName;
try {
fullImportedTemplateName = env.toFullTemplateName(getTemplate().getName(), importedTemplateName);
} catch (MalformedTemplateNameException e) {
throw new _MiscTemplateException(e, env,
"Malformed template name ", new _DelayedJQuote(e.getTemplateName()), ":\n",
e.getMalformednessDescription());
}
try {
env.importLib(fullImportedTemplateName, targetNsVarName);
} catch (IOException e) {
throw new _MiscTemplateException(e, env,
"Template importing failed (for parameter value ",
new _DelayedJQuote(importedTemplateName),
"):\n", new _DelayedGetMessage(e));
}
return null;
}
代码示例来源:origin: org.freemarker/freemarker-gae
absTemplateName = env.toFullTemplateName(env.getCurrentTemplate().getName(), templateName);
} catch (MalformedTemplateNameException e) {
throw new _TemplateModelException(
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
final String fullIncludedTemplateName;
try {
fullIncludedTemplateName = env.toFullTemplateName(getTemplate().getName(), includedTemplateName);
} catch (MalformedTemplateNameException e) {
throw new _MiscTemplateException(e, env,
内容来源于网络,如有侵权,请联系作者删除!