/** * * @param segment * @return the name for one-off lambda, e.g. "oneoff_lambda_10_4242" * @see Lambda#isReturnValueInterpolated() */ public static String constructLambdaOneoffTemplateName(Segment segment) { final Template template = segment.getOrigin().getTemplate(); return new StringBuilder() .append(Lambda.ONEOFF_LAMBDA_TEMPLATE_PREFIX) .append(template.getGeneratedId()) .append("_") .append(template.getEngine().getConfiguration() .getIdentifierGenerator().generate(null)) .toString(); } }
.getIdentifierGenerator().generate(Mustache.class), container.getContent(), engine); nested.initRootSegment(nestedBase.asSegment(nested));
@Override public void endTemplate() { RootSegmentBase rootSegmentBase = validate(); // Post processing if (engine.getConfiguration() .getBooleanPropertyValue(REMOVE_STANDALONE_LINES)) { SegmentBases.removeStandaloneLines(rootSegmentBase); } if (engine.getConfiguration() .getBooleanPropertyValue(REMOVE_UNNECESSARY_SEGMENTS)) { SegmentBases.removeUnnecessarySegments(rootSegmentBase); } if (engine.getConfiguration() .getBooleanPropertyValue(REUSE_LINE_SEPARATOR_SEGMENTS)) { SegmentBases.reuseLineSeparatorSegments(rootSegmentBase); } template = new Template(engine.getConfiguration() .getIdentifierGenerator().generate(Mustache.class), templateName, engine, nestedTemplates); template.initRootSegment(rootSegmentBase.asSegment(template)); for (Template nested : nestedTemplates) { nested.initParent(template); } LOGGER.debug("Compilation of {} finished [time: {} ms, segments: {}]", templateName, System.currentTimeMillis() - start, template.getRootSegment().getSegmentsSize(true)); nestedTemplates.clear(); containerStack.clear(); }
@Override public void render(Appendable appendable, Object data) { DefaultMustacheRenderingEvent event = new DefaultMustacheRenderingEvent( engine.getConfiguration().getIdentifierGenerator() .generate(MustacheRenderingEvent.class)); try { renderingStarted(event); appendable = rootSegment.execute(appendable, data != null ? globalExecutionContext.setContextObject(data) : globalExecutionContext); // We need for flush the async appendable if needed RootSegment.flushAsyncAppendable(appendable); renderingFinished(event); } finally { event.release(); } }