/** * Initializes the evaluation context with settings from the engine. * * @param locale The desired locale * @return The evaluation context */ private EvaluationContextImpl initContext(Locale locale) { locale = locale == null ? this.engine.getDefaultLocale() : locale; // globals ScopeChain scopeChain = new ScopeChain(); Map<String, Object> globals = new HashMap<>(); globals.put("locale", locale); globals.put("template", this); globals.put("_context", new GlobalContext(scopeChain)); scopeChain.pushScope(globals); // global vars provided from extensions scopeChain.pushScope(this.engine.getExtensionRegistry().getGlobalVariables()); return new EvaluationContextImpl(this, this.engine.isStrictVariables(), locale, this.engine.getExtensionRegistry(), this.engine.getTagCache(), this.engine.getExecutorService(), new ArrayList<>(), new HashMap<>(), scopeChain, null, this.engine.getEvaluationOptions()); }
/** * Initializes the evaluation context with settings from the engine. * * @param locale The desired locale * @return The evaluation context */ private EvaluationContextImpl initContext(Locale locale) { locale = locale == null ? this.engine.getDefaultLocale() : locale; // globals ScopeChain scopeChain = new ScopeChain(); Map<String, Object> globals = new HashMap<>(); globals.put("locale", locale); globals.put("template", this); globals.put("_context", new GlobalContext(scopeChain)); scopeChain.pushScope(globals); // global vars provided from extensions scopeChain.pushScope(this.engine.getExtensionRegistry().getGlobalVariables()); return new EvaluationContextImpl(this, this.engine.isStrictVariables(), locale, this.engine.getExtensionRegistry(), this.engine.getTagCache(), this.engine.getExecutorService(), new ArrayList<>(), new HashMap<>(), scopeChain, null, this.engine.getEvaluationOptions()); }