本文整理汇总了Java中org.jpublish.Template类的典型用法代码示例。如果您正苦于以下问题:Java Template类的具体用法?Java Template怎么用?Java Template使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Template类属于org.jpublish包,在下文中一共展示了Template类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureTemplate
import org.jpublish.Template; //导入依赖的package包/类
/**
* Configure the template.
*
* @param template The Template
* @param file The file for the template
* @throws Exception Any exception
* @since 2.0
*/
protected void configureTemplate(Template template, File file) throws Exception {
// load additional configuration information
// note that if there is a template with the ending .xml
// then this will cause a naming conflict.
File parentFile = file.getParentFile();
String name = file.getName();
String namePart = name.substring(0, name.lastIndexOf("."));
String configFileName = namePart + ".xml";
File configFile = new File(parentFile, configFileName);
if (configFile.exists()) {
template.loadConfiguration(configFileName, configFile);
}
}
示例2: saveTemplate
import org.jpublish.Template; //导入依赖的package包/类
/**
* Save the template to the specified file location.
*
* @param template The Template
* @param file The File
* @throws IOException
*/
protected synchronized void saveTemplate(Template template, File file)
throws IOException {
PrintWriter writer = null;
try {
writer = new PrintWriter(new FileWriter(file));
writer.print(template.getText());
} finally {
IOUtilities.close(writer);
}
}
示例3: renderTemplate
import org.jpublish.Template; //导入依赖的package包/类
private void renderTemplate(JPublishContext context, Page page, Writer out) throws IOException, ViewRenderException {
context.disableCheckReservedNames(this);
context.put("page", page);
if (siteContext.isProtectReservedNames()) {
context.enableCheckReservedNames(this);
}
try {
Debug.logInfo("Merging template", module);
Template template = siteContext.getTemplateManager().getTemplate(page.getFullTemplateName());
template.merge(context, page, out);
} catch (Exception e) {
throw new ViewRenderException(e);
}
}
示例4: loadTemplate
import org.jpublish.Template; //导入依赖的package包/类
/**
* Load the specified template's text.
* <p/>
* <p><b>Note:</b> Template encoding is currently disabled. The original
* encoding mechanism was based on the page path. However, now that
* templates will be loaded and cached independent of a request path,
* this will need to change. The new encoding system should be based
* on the template path, not the page path.</p>
*
* @param template The Template
* @param path to the Template
* @throws IOException
*/
protected synchronized void loadTemplate(Template template, String path) throws IOException {
// construct a new Template
//String templateEncoding = siteContext.getCharacterEncodingManager().getMap(path).getTemplateEncoding();
File templateFile = new File(getRoot(), path);
//Reader reader = new InputStreamReader(new FileInputStream(templateFile), templateEncoding);
Reader reader = new InputStreamReader(new FileInputStream(templateFile));
template.setText(FileCopyUtils.copyToString(reader));
}
示例5: putTemplate
import org.jpublish.Template; //导入依赖的package包/类
/**
* Put the template in the location specified by the given path.
*
* @param path The template path
* @param template The Template
* @throws Exception
*/
public void putTemplate(String path, Template template) throws Exception {
File templateFile = new File(getRoot(), path);
saveTemplate(template, templateFile);
}
示例6: TemplateCacheEntry
import org.jpublish.Template; //导入依赖的package包/类
/** Construct a new TemplateCacheEntry for the given template.
@param template The template
@param lastModified The last modification time in milliseconds
*/
public TemplateCacheEntry(Template template, long lastModified){
this.template = template;
this.lastModified = lastModified;
}
示例7: getTemplate
import org.jpublish.Template; //导入依赖的package包/类
/** Get the template for this cache entry.
@return The Template
*/
public Template getTemplate(){
return template;
}
示例8: TemplateContent
import org.jpublish.Template; //导入依赖的package包/类
/**
* Construct a new TemplateContent object.
*
* @param template The template
*/
public TemplateContent(Template template) {
this.template = template;
}