private void initializeImportLibNamespace(final Namespace newNamespace, Template loadedTemplate) throws TemplateException, IOException { Namespace prevNamespace = this.currentNamespace; this.currentNamespace = newNamespace; Writer prevOut = out; this.out = NullWriter.INSTANCE; try { include(loadedTemplate); } finally { this.out = prevOut; this.currentNamespace = prevNamespace; } }
/** * Emulates <code>include</code> directive, except that <code>name</code> must be template root relative. * * <p> * It's the same as <code>include(getTemplateForInclusion(name, encoding, parse))</code>. But, you may want to * separately call these two methods, so you can determine the source of exceptions more precisely, and thus achieve * more intelligent error handling. * * @see #getTemplateForInclusion(String name, String encoding, boolean parse) * @see #include(Template includedTemplate) */ public void include(String name, String encoding, boolean parse) throws IOException, TemplateException { include(getTemplateForInclusion(name, encoding, parse)); }
private void doAutoIncludes(Environment env, Template t) throws TemplateException, IOException, TemplateNotFoundException, MalformedTemplateNameException, ParseException { // We can't store autoIncludes in LinkedHashSet-s because setAutoIncludes(List) allows duplicates, // unfortunately. Yet we have to prevent duplicates among Configuration levels, with the lowest levels having // priority. So we build some Set-s to do that, but we avoid the most common cases where they aren't needed. List<String> tAutoIncludes = t.getAutoIncludesWithoutFallback(); List<String> envAutoIncludes = env.getAutoIncludesWithoutFallback(); for (String templateName : getAutoIncludesWithoutFallback()) { if ((tAutoIncludes == null || !tAutoIncludes.contains(templateName)) && (envAutoIncludes == null || !envAutoIncludes.contains(templateName))) { env.include(getTemplate(templateName, env.getLocale())); } } if (tAutoIncludes != null) { for (String templateName : tAutoIncludes) { if (envAutoIncludes == null || !envAutoIncludes.contains(templateName)) { env.include(getTemplate(templateName, env.getLocale())); } } } if (envAutoIncludes != null) { for (String templateName : envAutoIncludes) { env.include(getTemplate(templateName, env.getLocale())); } } }
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { if (!params.isEmpty()) { throw new TemplateException("This directive supports no parameters.", env); } if (loopVars.length != 0) { throw new TemplateException("This directive supports no loop variables.", env); } if (body != null) { throw new TemplateException("This directive supports no nested content.", env); } env.include(template); } });
boolean lastFIRE = env.setFastInvalidReferenceExceptions(false); try { env.include(template); } finally { env.setFastInvalidReferenceExceptions(lastFIRE);
env.include(includedTemplate);
@Override public void execute(Environment environment, @SuppressWarnings("rawtypes") Map parameters, TemplateModel[] loopVars, TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException { @SuppressWarnings("unchecked") String path = TemplateModelUtils.converString(((Map<String, TemplateModel>) parameters).get("path")); if (CommonUtils.notEmpty(path) && null != environment) { environment.include(SiteComponent.getFullTemplatePath(site, path), CommonConstants.DEFAULT_CHARSET_NAME, true); } } }
@Override public void execute(Environment environment, @SuppressWarnings("rawtypes") Map parameters, TemplateModel[] loopVars, TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException { @SuppressWarnings("unchecked") String path = TemplateModelUtils.converString(((Map<String, TemplateModel>) parameters).get("path")); if (CommonUtils.notEmpty(path) && null != environment) { environment.include(SiteComponent.getFullTemplatePath(site, path), CommonConstants.DEFAULT_CHARSET_NAME, true); } } }
private void initializeImportLibNamespace(final Namespace newNamespace, Template loadedTemplate) throws TemplateException, IOException { Namespace prevNamespace = this.currentNamespace; this.currentNamespace = newNamespace; Writer prevOut = out; this.out = NullWriter.INSTANCE; try { include(loadedTemplate); } finally { this.out = prevOut; this.currentNamespace = prevNamespace; } }
private void processLayout(Environment env, String layoutName) throws IOException, TemplateException { env.include(layoutName, null, true); } }
private void initializeImportLibNamespace(final Namespace newNamespace, Template loadedTemplate) throws TemplateException, IOException { Namespace prevNamespace = this.currentNamespace; this.currentNamespace = newNamespace; Writer prevOut = out; this.out = NullWriter.INSTANCE; try { include(loadedTemplate); } finally { this.out = prevOut; this.currentNamespace = prevNamespace; } }
/** * Emulates <code>include</code> directive, except that <code>name</code> must be template root relative. * * <p> * It's the same as <code>include(getTemplateForInclusion(name, encoding, parse))</code>. But, you may want to * separately call these two methods, so you can determine the source of exceptions more precisely, and thus achieve * more intelligent error handling. * * @see #getTemplateForInclusion(String name, String encoding, boolean parse) * @see #include(Template includedTemplate) */ public void include(String name, String encoding, boolean parse) throws IOException, TemplateException { include(getTemplateForInclusion(name, encoding, parse)); }
protected void doAutoImportsAndIncludes(Environment env) throws TemplateException, IOException { for (int i=0; i<autoImports.size(); i++) { String namespace = (String) autoImports.get(i); String templateName = (String) autoImportMap.get(namespace); env.importLib(templateName, namespace); } for (int i = 0; i < autoIncludes.size(); i++) { String templateName = (String) autoIncludes.get(i); Template template = getTemplate(templateName, env.getLocale()); env.include(template); } }
private void executeMacro(String macro) { try { Reader templateReader = new StringReader(macro); // FIXME: I am using a Date as an hack to provide a unique name for the template... Template template = new Template((new java.util.Date()).toString(), templateReader, FreeMarkerWorker.getDefaultOfbizConfig()); templateReader.close(); this.environment.include(template); } catch (TemplateException | IOException e) { Debug.logError(e, "Error rendering tree thru ftl", module); } }
private void executeMacro(Appendable writer, String macro) throws IOException { try { Environment environment = getEnvironment(writer); Reader templateReader = new StringReader(macro); // FIXME: I am using a Date as an hack to provide a unique name for the template... Template template = new Template((new java.util.Date()).toString(), templateReader, FreeMarkerWorker.getDefaultOfbizConfig()); templateReader.close(); environment.include(template); } catch (TemplateException |IOException e) { Debug.logError(e, "Error rendering screen macro [" + macro + "] thru ftl", module); } }
private void executeMacro(Appendable writer, String macro) throws IOException, TemplateException { Environment environment = getEnvironment(writer); environment.setVariable("visualTheme", FreeMarkerWorker.autoWrap(visualTheme, environment)); Reader templateReader = new StringReader(macro); macroCount++; String templateName = toString().concat("_") + macroCount; Template template = new Template(templateName, templateReader, FreeMarkerWorker.getDefaultOfbizConfig()); templateReader.close(); environment.include(template); }
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { if (!params.isEmpty()) { throw new TemplateException("This directive supports no parameters.", env); } if (loopVars.length != 0) { throw new TemplateException("This directive supports no loop variables.", env); } if (body != null) { throw new TemplateException("This directive supports no nested content.", env); } env.include(template); } });
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { if (!params.isEmpty()) { throw new TemplateException("This directive supports no parameters.", env); } if (loopVars.length != 0) { throw new TemplateException("This directive supports no loop variables.", env); } if (body != null) { throw new TemplateException("This directive supports no nested content.", env); } env.include(template); } });
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { String name = DirectiveUtils.getRequiredParam(params, "name"); String encoding = DirectiveUtils.getParam(params, "encoding",null); String includeTemplateName = TemplateCache.getFullTemplatePath(env, getTemplatePath(env), name); env.include(includeTemplateName, encoding, true); }
private void executeMacro(Appendable writer, String macro) { try { Environment environment = getEnvironment(writer); environment.setVariable("visualTheme", FreeMarkerWorker.autoWrap(visualTheme, environment)); environment.setVariable("modelTheme", FreeMarkerWorker.autoWrap(visualTheme.getModelTheme(), environment)); Reader templateReader = new StringReader(macro); Template template = new Template(new UID().toString(), templateReader, FreeMarkerWorker.getDefaultOfbizConfig()); templateReader.close(); environment.include(template); } catch (TemplateException | IOException e) { Debug.logError(e, "Error rendering screen thru ftl, macro: " + macro, module); } }