if (rendererName != null && !rendererName.equals("")) { final NamedRenderer rendererForName = context .resolveNamedRenderer(rendererName); if (rendererForName != null) { if (rendererForName instanceof RawRenderer) { } else { final Renderer<Object> rendererForClass = (Renderer<Object>) context .resolveRendererForClass(value.getClass()); if (rendererForClass != null) { if (rendererForClass instanceof RawRenderer) { } else { final String prefixedRenderedResult = (prefix != null ? prefix : "") + renderedResult + (suffix != null ? suffix : ""); Encoder encoder = context.getEncoder(); if (!rawRendering && encoder != null) { final String encodedPrefixedRenderedResult = encoder.encode(prefixedRenderedResult);
public Object evaluate(TemplateContext context) { AnnotationProcessor<?> annotationProcessor = context .resolveAnnotationProcessor(receiver); if (annotationProcessor != null) { Object value = annotationProcessor.eval(this, context); if (value != null) { return value; } } return ""; } }
tokenStream.consume(); context.push(ifToken); try { boolean localSkip; localSkip = !localSkip; context.notifyProcessListener(contentToken, inheritedSkip ? Action.SKIP : Action.EVAL); } else { tokenStream.consume(); context.notifyProcessListener(contentToken, Action.END); context.pop();
@Override public synchronized String transform(Map<String, Object> model, Locale locale, ModelAdaptor modelAdaptor, ProcessListener processListener) { TemplateContext context = new TemplateContext(template, locale, sourceName, new ScopedMap(model), modelAdaptor, engine, engine.getErrorHandler(), processListener); String transformed = transformCompiled(context); return transformed; }
} else if (value != null) { final Renderer<Object> rendererForClass = (Renderer<Object>) context .resolveRendererForClass(value.getClass()); if (rendererForClass != null) { if (rendererForClass instanceof RawRenderer) { final Encoder encoder = context.getEncoder(); if (!rawRendering && encoder != null) { final String encodedPrefixedRenderedResult = encoder.encode(prefixedRenderedResult);
private NamedRenderer resolveNamedRenderer(TemplateContext context) { if (this.rendererName != null && !this.rendererName.equals("")) { return context.resolveNamedRenderer(rendererName); } else { return null; } }
private void content(boolean skip) { Token token = tokenStream.currentToken(); context.notifyProcessListener(token, skip ? Action.SKIP : Action.EVAL); if (token instanceof PlainTextToken) { tokenStream.consume();
tokenStream.consume(); context.push(ifToken); try { boolean localSkip; localSkip = !localSkip; context.notifyProcessListener(contentToken, inheritedSkip ? Action.SKIP : Action.EVAL); } else { tokenStream.consume(); context.notifyProcessListener(contentToken, Action.END); context.pop();
@Override public synchronized String transform(Map<String, Object> model, Locale locale, ModelAdaptor modelAdaptor, ProcessListener processListener) { try { context = new TemplateContext(template, locale, sourceName, new ScopedMap( model), modelAdaptor, engine, engine.getErrorHandler(), processListener); String transformed = transformPure(context); return transformed; } finally { context = null; } }
private NamedRenderer resolveNamedRenderer(TemplateContext context) { if (this.rendererName != null && !this.rendererName.equals("")) { return context.resolveNamedRenderer(rendererName); } else { return null; } }
private void content(boolean skip) { Token token = tokenStream.currentToken(); context.notifyProcessListener(token, skip ? Action.SKIP : Action.EVAL); if (token instanceof PlainTextToken) { tokenStream.consume();
context.push(feToken); try { } else { tokenStream.consume(); context.notifyProcessListener(contentToken, Action.END); } else { tokenStream.consume(); context.notifyProcessListener(contentToken, Action.END); context.pop();
@Override public synchronized String transform(Map<String, Object> model, Locale locale, ModelAdaptor modelAdaptor, ProcessListener processListener) { try { context = new TemplateContext(template, locale, sourceName, new ScopedMap( model), modelAdaptor, engine, engine.getErrorHandler(), processListener); String transformed = transformPure(context); return transformed; } finally { context = null; output = null; } }
public Object evaluate(TemplateContext context) { AnnotationProcessor<?> annotationProcessor = context .resolveAnnotationProcessor(receiver); if (annotationProcessor != null) { Object value = annotationProcessor.eval(this, context); if (value != null) { return value; } } return ""; } }
context.push(feToken); try { } else { tokenStream.consume(); context.notifyProcessListener(contentToken, Action.END); } else { tokenStream.consume(); context.notifyProcessListener(contentToken, Action.END); context.pop();
@Override public List<ErrorEntry> getStaticErrors() { final Engine engine = new Engine(); final JournalingErrorHandler errorHandler = new JournalingErrorHandler(); engine.setErrorHandler(errorHandler); final ScopedMap scopedMap = new ScopedMap(Collections.EMPTY_MAP); final Locale locale = Locale.getDefault(); this.context = new TemplateContext(this.template, locale, this.sourceName, scopedMap, new DefaultModelAdaptor(), engine, errorHandler, null); transformPure(this.context); final List<ErrorEntry> staticErrors = new ArrayList<>(); for (ErrorEntry entry: errorHandler.entries) { if (entry.errorMessage.isStatic) { staticErrors.add(entry); } } return staticErrors; }
context = new TemplateContext(template, locale, sourceName, scopedMap, new DefaultModelAdaptor(), engine, engine.getErrorHandler(), processListener);
/** * Checks if all given variables are there and if so, that they evaluate to true inside an if. */ public boolean variablesAvailable(Map<String, Object> model, String... vars) { final TemplateContext context = new TemplateContext(null, null, null, new ScopedMap(model), modelAdaptor, this, new SilentErrorHandler(), null); for (String var : vars) { final IfToken token = new IfToken(var, false); if (!(Boolean) token.evaluate(context)) { return false; } } return true; }
/** * Checks if all given variables are there and if so, that they evaluate to true inside an if. */ public boolean variablesAvailable(Map<String, Object> model, String... vars) { final TemplateContext context = new TemplateContext(null, null, null, new ScopedMap(model), modelAdaptor, this, new SilentErrorHandler(), null); for (String var : vars) { final IfToken token = new IfToken(var, false); if (!(Boolean) token.evaluate(context)) { return false; } } return true; }
this.context = new TemplateContext(this.template, locale, this.sourceName, scopedMap, new DefaultModelAdaptor(), engine, engine.getErrorHandler(), processListener); transformPure(this.context);