use of org.apache.velocity.VelocityContext in project markdown-doclet by Abnaxos.
the class GistMarkdownTaglet method applyGistTemplate.
private String applyGistTemplate(GHGist gist, GHGistFile gistFile, boolean firstGistFile) {
final VelocityContext context = new VelocityContext();
context.put("gist", gist);
context.put("gistFile", gistFile);
context.put("renderDescription", firstGistFile && useGistDescription);
final StringWriter templateWriter = new StringWriter();
template.merge(context, templateWriter);
return templateWriter.toString();
}
use of org.apache.velocity.VelocityContext in project traccar by traccar.
the class NotificationFormatter method formatMailMessage.
public static MailMessage formatMailMessage(long userId, Event event, Position position) {
String templatePath = Context.getConfig().getString("mail.templatesPath", "mail");
VelocityContext velocityContext = prepareContext(userId, event, position);
String formattedMessage = formatMessage(velocityContext, userId, event, position, templatePath);
return new MailMessage((String) velocityContext.get("subject"), formattedMessage);
}
use of org.apache.velocity.VelocityContext in project traccar by traccar.
the class NotificationFormatter method formatMessage.
private static String formatMessage(VelocityContext vc, Long userId, Event event, Position position, String templatePath) {
VelocityContext velocityContext = vc;
if (velocityContext == null) {
velocityContext = prepareContext(userId, event, position);
}
StringWriter writer = new StringWriter();
getTemplate(event, templatePath).merge(velocityContext, writer);
return writer.toString();
}
use of org.apache.velocity.VelocityContext in project selenium_java by sergueik.
the class CucumberITGenerator method writeContentFromTemplate.
private void writeContentFromTemplate(final Writer writer) {
final VelocityContext context = new VelocityContext();
context.put("strict", overriddenParameters.isStrict());
context.put("featureFile", featureFileLocation);
context.put("reports", createFormatStrings());
context.put("tags", overriddenParameters.getTags());
context.put("monochrome", overriddenParameters.isMonochrome());
context.put("cucumberOutputDir", config.getCucumberOutputDir());
context.put("glue", quoteGlueStrings());
context.put("className", FilenameUtils.removeExtension(outputFileName));
velocityTemplate.merge(context, writer);
}
use of org.apache.velocity.VelocityContext in project pac4j by pac4j.
the class Pac4jHTTPPostEncoder method postEncode.
protected void postEncode(final MessageContext<SAMLObject> messageContext, final String endpointURL) throws MessageEncodingException {
log.debug("Invoking Velocity template to create POST body");
try {
final VelocityContext e = new VelocityContext();
this.populateVelocityContext(e, messageContext, endpointURL);
responseAdapter.setContentType("text/html");
responseAdapter.init();
final OutputStreamWriter out = responseAdapter.getOutputStreamWriter();
this.getVelocityEngine().mergeTemplate(this.getVelocityTemplateId(), "UTF-8", e, out);
out.flush();
} catch (Exception var6) {
throw new MessageEncodingException("Error creating output document", var6);
}
}
Aggregations