/** * Creates a new TemplateFactory * <p/> * The template lookup is made on the classpath. The template path * should be provided as com/yourcompany/packages/index.html * <p/> * This method also accepts a TemplateModifier which will be called * right after the template parsing finishes. * * @param template The template path * @param modifier The template modifier that will alter the structure of the template * @return Returns the newly created TemplateFactory * @throws TemplateLoadingException */ public TemplateFactory newTemplateFactory(String template, TemplateModifier modifier, ExpressionLanguage expressionLanguage) throws TemplateLoadingException { InputStream in = classLoader.getResourceAsStream(template); TemplateDocument doc = parseTemplate(in, expressionLanguage); modifier.modifyTemplate(doc); try { FragmentList fragments = doc.normalize(); return new ImmutableTemplateFactory(this, fragments); } catch (BehaviorInstantiationException e) { throw new TemplateLoadingException(e); } }
/** * Creates a new TemplateFactory * <p/> * The template lookup is made on the classpath. The template path * should be provided as com/yourcompany/packages/index.html * <p/> * This method also accepts a TemplateModifier which will be called * right after the template parsing finishes. * * @param template The template path * @param encoding The encoding to be used while parsing the template * @param modifier The template modifier that will alter the structure of the template * @return Returns the newly created TemplateFactory * @throws TemplateLoadingException */ public TemplateFactory newTemplateFactory(String template, String encoding, TemplateModifier modifier, ExpressionLanguage expressionLanguage) throws TemplateLoadingException { InputStream in = classLoader.getResourceAsStream(template); TemplateDocument doc = parseTemplate(in, encoding, expressionLanguage); modifier.modifyTemplate(doc); try { FragmentList fragments = doc.normalize(); return new ImmutableTemplateFactory(this, fragments); } catch (BehaviorInstantiationException e) { throw new TemplateLoadingException(e); } }
if (modifier != null) modifier.modifyTemplate(doc);
public TemplateFactory newTemplateFactory(File file, String encoding, TemplateModifier modifier, ExpressionLanguage expressionLanguage) throws TemplateLoadingException { TemplateDocument document = parseTemplate(file, encoding, expressionLanguage); if (modifier != null) { modifier.modifyTemplate(document); } try { if (document.getIncludes() != null) { return new FileTemplateFactory(this, document.normalize(), file, encoding, modifier, getFiles(document.getIncludes()), changeDetectionInterval); } return new FileTemplateFactory(this, document.normalize(), file, encoding, modifier, null, changeDetectionInterval); } catch (BehaviorInstantiationException e) { throw new TemplateLoadingException(e); } }