Context(Environment env, TemplateObject callPlace, List nestedContentParameterNames) { this.localVars = env.new Namespace(); this.callPlace = callPlace; this.nestedContentNamespace = env.getCurrentNamespace(); this.nestedContentParameterNames = nestedContentParameterNames; this.prevLocalContextStack = env.getLocalContextStack(); this.prevMacroContext = env.getCurrentMacroContext(); }
@Override public TemplateModel get(String key) throws TemplateModelException { if ("currentNamespace".equals(key)) { return ((Environment) configurable).getCurrentNamespace(); } if ("dataModel".equals(key)) { return ((Environment) configurable).getDataModel(); } if ("globalNamespace".equals(key)) { return ((Environment) configurable).getGlobalNamespace(); } if ("knownVariables".equals(key)) { return knownVariables; } if ("mainNamespace".equals(key)) { return ((Environment) configurable).getMainNamespace(); } if ("template".equals(key)) { try { return (TemplateModel) getCachedWrapperFor(((Environment) configurable).getTemplate()); } catch (RemoteException e) { throw new TemplateModelException(e); } } return super.get(key); } }
private void reduce(Map<String, TemplateModel> reduceMap) { if (CommonUtils.notEmpty(reduceMap)) { Namespace namespace = environment.getCurrentNamespace(); namespace.putAll(reduceMap); } }
private void reduce(Map<String, TemplateModel> reduceMap) { if (CommonUtils.notEmpty(reduceMap)) { Namespace namespace = environment.getCurrentNamespace(); namespace.putAll(reduceMap); } }
private Map<String, TemplateModel> reduce() throws TemplateModelException { Map<String, TemplateModel> reduceMap = new LinkedHashMap<>(); ObjectWrapper objectWrapper = environment.getObjectWrapper(); Namespace namespace = environment.getCurrentNamespace(); Iterator<Entry<String, Object>> iterator = map.entrySet().iterator(); for (int i = 0; iterator.hasNext(); i++) { Entry<String, Object> entry = iterator.next(); if (i < loopVars.length) { loopVars[i] = objectWrapper.wrap(entry.getValue()); } else { String key = entry.getKey(); reduceMap.put(key, namespace.get(key)); namespace.put(key, objectWrapper.wrap(entry.getValue())); } } return reduceMap; }
return env.getCurrentNamespace();
private Map<String, TemplateModel> reduce() throws TemplateModelException { Map<String, TemplateModel> reduceMap = new LinkedHashMap<>(); ObjectWrapper objectWrapper = environment.getObjectWrapper(); Namespace namespace = environment.getCurrentNamespace(); Iterator<Entry<String, Object>> iterator = map.entrySet().iterator(); for (int i = 0; iterator.hasNext(); i++) { Entry<String, Object> entry = iterator.next(); if (i < loopVars.length) { loopVars[i] = objectWrapper.wrap(entry.getValue()); } else { String key = entry.getKey(); reduceMap.put(key, namespace.get(key)); namespace.put(key, objectWrapper.wrap(entry.getValue())); } } return reduceMap; }
break; case NAMESPACE: namespace = env.getCurrentNamespace(); break; default:
Context(Environment env, TemplateObject callPlace, List nestedContentParameterNames) { this.localVars = env.new Namespace(); this.callPlace = callPlace; this.nestedContentNamespace = env.getCurrentNamespace(); this.nestedContentParameterNames = nestedContentParameterNames; this.prevLocalContextStack = env.getLocalContextStack(); this.prevMacroContext = env.getCurrentMacroContext(); }
Context(Environment env, TemplateObject callPlace, List nestedContentParameterNames) { this.localVars = env.new Namespace(); this.callPlace = callPlace; this.nestedContentNamespace = env.getCurrentNamespace(); this.nestedContentParameterNames = nestedContentParameterNames; this.prevLocalContextStack = env.getLocalContextStack(); this.prevMacroContext = env.getCurrentMacroContext(); }
Context(Environment env, TemplateElement body, List bodyParameterNames) { this.localVars = env.new Namespace(); this.prevMacroContext = env.getCurrentMacroContext(); this.bodyNamespace = env.getCurrentNamespace(); this.prevLocalContextStack = env.getLocalContextStack(); this.body = body; this.bodyParameterNames = bodyParameterNames; }
public Writer pipeline(String pipeTemplates[],Object rootMap,Writer writer) throws PipeException { try { Map globalContext = new HashMap(); for(int i = 0; i < pipeTemplates.length; i++) { String templateName = pipeTemplates[i]; boolean isLastTemplate = i == pipeTemplates.length - 1; try { Template template = conf.getTemplate(templateName); if(isLastTemplate) { Environment env = template.createProcessingEnvironment(rootMap, writer); env.getCurrentNamespace().putAll(globalContext); env.process(); }else { Writer tempOutput = new StringWriter(bufferSize); Environment env = template.createProcessingEnvironment(rootMap, tempOutput); env.getCurrentNamespace().putAll(globalContext); env.process(); globalContext.putAll(env.getCurrentNamespace().toMap()); globalContext.put(Pipeline.PIPELINE_CONTENT_VAR_NAME, tempOutput.toString()); } }catch(Exception e){ handleException(e,templateName,isLastTemplate); } } return writer; }catch(Exception e) { throw new PipeException("process FreeMarker template occer exception,pipeTemplates:"+StringUtils.join(pipeTemplates," | "),e); } }
@Override public TemplateModel get(String key) throws TemplateModelException { if ("currentNamespace".equals(key)) { return ((Environment) configurable).getCurrentNamespace(); } if ("dataModel".equals(key)) { return ((Environment) configurable).getDataModel(); } if ("globalNamespace".equals(key)) { return ((Environment) configurable).getGlobalNamespace(); } if ("knownVariables".equals(key)) { return knownVariables; } if ("mainNamespace".equals(key)) { return ((Environment) configurable).getMainNamespace(); } if ("template".equals(key)) { try { return (TemplateModel) getCachedWrapperFor(((Environment) configurable).getTemplate()); } catch (RemoteException e) { throw new TemplateModelException(e); } } return super.get(key); } }
@Override public TemplateModel get(String key) throws TemplateModelException { if ("currentNamespace".equals(key)) { return ((Environment) configurable).getCurrentNamespace(); } if ("dataModel".equals(key)) { return ((Environment) configurable).getDataModel(); } if ("globalNamespace".equals(key)) { return ((Environment) configurable).getGlobalNamespace(); } if ("knownVariables".equals(key)) { return knownVariables; } if ("mainNamespace".equals(key)) { return ((Environment) configurable).getMainNamespace(); } if ("template".equals(key)) { try { return (TemplateModel) getCachedWrapperFor(((Environment) configurable).getTemplate()); } catch (RemoteException e) { throw new TemplateModelException(e); } } return super.get(key); } }
return ((Environment)configurable).getCurrentNamespace();
@Override protected boolean preprocessRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Environment environment = Environment.getCurrentEnvironment(); if (environment != null) { try { Namespace namespace = environment.getCurrentNamespace(); TemplateCollectionModel collectionModel = namespace.keys(); TemplateModelIterator iterator = collectionModel.iterator(); Map<String, Object> sharedVariables = new HashMap<>(); while (iterator.hasNext()) { SimpleScalar scalar = (SimpleScalar) iterator.next(); TemplateModel value = namespace.get(scalar.getAsString()); sharedVariables.put(scalar.getAsString(), value); } addSharedVariables(getConfiguration(), sharedVariables); } catch (TemplateModelException e) { throw new ServletException(e); } } return false; }
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException { if (name == NAMESPACE) { return env.getCurrentNamespace();
namespace = env.getCurrentNamespace();
break; case NAMESPACE: namespace = env.getCurrentNamespace(); break; default:
break; case NAMESPACE: namespace = env.getCurrentNamespace(); break; default: