@Override public void render(final View view, final Renderer.Context ctx) throws Exception { String name = view.name() + suffix; Template template = template(name, ctx.charset()); Map<String, Object> hash = new HashMap<>(); hash.put("_vname", view.name()); hash.put("_vpath", template.getName()); hash.put("xss", xss); // Locale: Locale locale = (Locale) hash.getOrDefault("locale", ctx.locale()); hash.putIfAbsent("locale", locale); // locals Map<String, Object> locals = ctx.locals(); hash.putAll(locals); // model hash.putAll(view.model()); TemplateModel model = new SimpleHash(hash, new FtlWrapper(freemarker.getObjectWrapper())); // TODO: remove string writer StringWriter writer = new StringWriter(); // Locale: template.setLocale(locale); // output template.process(model, writer); ctx.type(MediaType.html) .send(writer.toString()); }
template.setLocale(locale); template.setCustomLookupCondition(customLookupCondition); return template;
interpretedTemplate.setLocale(env.getLocale()); return new TemplateProcessorModel(interpretedTemplate);
template.setLocale(getLocale());
protected void render(Reader template, Locale locale, String i18nBasename, Object root, Writer out) throws TemplateException, IOException { final Locale localeToUse = checkLocale(locale); prepareRendering(localeToUse, i18nBasename, root); final Template t = new Template("inlinetemplate", template, cfg); t.setLocale(localeToUse); t.process(root, out); }
/** * @see org.pivot4j.el.AbstractExpressionEvaluator#doEvaluate(java.lang.String, * org.pivot4j.el.ExpressionContext) */ @Override protected Object doEvaluate(String expression, ExpressionContext context) throws Exception { Template template = getTemplateFromCache(expression); if (template == null) { template = createTemplate(expression); } Locale locale = (Locale) context.get("locale"); if (locale != null) { template.setLocale(locale); } StringWriter writer = new StringWriter(); template.process(context, writer); writer.flush(); return writer.toString(); } }
@Override public void render(final View view, final Renderer.Context ctx) throws Exception { String name = view.name() + suffix; Template template = template(name, ctx.charset()); Map<String, Object> hash = new HashMap<>(); hash.put("_vname", view.name()); hash.put("_vpath", template.getName()); hash.put("xss", xss); // Locale: Locale locale = (Locale) hash.getOrDefault("locale", ctx.locale()); hash.putIfAbsent("locale", locale); // locals Map<String, Object> locals = ctx.locals(); hash.putAll(locals); // model hash.putAll(view.model()); TemplateModel model = new SimpleHash(hash, new FtlWrapper(freemarker.getObjectWrapper())); // TODO: remove string writer StringWriter writer = new StringWriter(); // Locale: template.setLocale(locale); // output template.process(model, writer); ctx.type(MediaType.html) .send(writer.toString()); }
template.setLocale(env.getLocale()); return new TemplateProcessorModel(template);
template.setLocale(locale); template.setCustomLookupCondition(customLookupCondition); return template;
template.setLocale(locale); template.setCustomLookupCondition(customLookupCondition); return template;
interpretedTemplate.setLocale(env.getLocale()); return new TemplateProcessorModel(interpretedTemplate);
interpretedTemplate.setLocale(env.getLocale()); return new TemplateProcessorModel(interpretedTemplate);
template.setLocale(getLocale());
template.setLocale(getLocale());