Search in sources :

Example 66 with VelocityContext

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();
}
Also used : StringWriter(java.io.StringWriter) VelocityContext(org.apache.velocity.VelocityContext)

Example 67 with VelocityContext

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);
}
Also used : VelocityContext(org.apache.velocity.VelocityContext)

Example 68 with VelocityContext

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();
}
Also used : StringWriter(java.io.StringWriter) VelocityContext(org.apache.velocity.VelocityContext)

Example 69 with VelocityContext

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);
}
Also used : VelocityContext(org.apache.velocity.VelocityContext)

Example 70 with VelocityContext

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);
    }
}
Also used : VelocityContext(org.apache.velocity.VelocityContext) OutputStreamWriter(java.io.OutputStreamWriter) MessageEncodingException(org.opensaml.messaging.encoder.MessageEncodingException) ComponentInitializationException(net.shibboleth.utilities.java.support.component.ComponentInitializationException) MarshallingException(org.opensaml.core.xml.io.MarshallingException) BindingException(org.opensaml.saml.common.binding.BindingException) MessageEncodingException(org.opensaml.messaging.encoder.MessageEncodingException)

Aggregations

VelocityContext (org.apache.velocity.VelocityContext)492 StringWriter (java.io.StringWriter)156 Template (org.apache.velocity.Template)120 Test (org.junit.Test)72 IOException (java.io.IOException)60 VelocityEngine (org.apache.velocity.app.VelocityEngine)53 File (java.io.File)47 ArrayList (java.util.ArrayList)39 HashMap (java.util.HashMap)36 Map (java.util.Map)36 Identity (org.olat.core.id.Identity)36 Context (org.apache.velocity.context.Context)32 MailTemplate (org.olat.core.util.mail.MailTemplate)28 Writer (java.io.Writer)22 Properties (java.util.Properties)20 ResourceNotFoundException (org.apache.velocity.exception.ResourceNotFoundException)19 ParseErrorException (org.apache.velocity.exception.ParseErrorException)16 ClasspathResourceLoader (org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader)16 FileWriter (java.io.FileWriter)15 OutputStreamWriter (java.io.OutputStreamWriter)14