当前位置: 首页>>代码示例>>Java>>正文


Java Template类代码示例

本文整理汇总了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);
    }

}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:27,代码来源:FileSystemTemplateManager.java

示例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);
    }
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:19,代码来源:FileSystemTemplateManager.java

示例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);
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:15,代码来源:GenericViewRenderer.java

示例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));
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:23,代码来源:FileSystemTemplateManager.java

示例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);
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:13,代码来源:FileSystemTemplateManager.java

示例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;
    }
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:11,代码来源:TemplateCacheEntry.java

示例7: getTemplate

import org.jpublish.Template; //导入依赖的package包/类
/**	Get the template for this cache entry.

        @return The Template
    */

    public Template getTemplate(){
        return template;
    }
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:9,代码来源:TemplateCacheEntry.java

示例8: TemplateContent

import org.jpublish.Template; //导入依赖的package包/类
/**
 * Construct a new TemplateContent object.
 *
 * @param template The template
 */

public TemplateContent(Template template) {
    this.template = template;
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:10,代码来源:TemplateContent.java


注:本文中的org.jpublish.Template类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。