Search in sources :

Example 6 with PebbleTemplate

use of com.mitchellbosecke.pebble.template.PebbleTemplate in project symja_android_library by axkr.

the class BoxTrace method asJavascript.

@Override
public String asJavascript(int i) {
    Writer writer = new StringWriter();
    PebbleTemplate compiledTemplate;
    try {
        compiledTemplate = engine.getTemplate("trace_template.html");
        compiledTemplate.evaluate(writer, getContext(i));
    } catch (PebbleException e) {
        throw new IllegalStateException(e);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return writer.toString();
}
Also used : PebbleException(com.mitchellbosecke.pebble.error.PebbleException) StringWriter(java.io.StringWriter) PebbleTemplate(com.mitchellbosecke.pebble.template.PebbleTemplate) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) StringWriter(java.io.StringWriter) Writer(java.io.Writer)

Example 7 with PebbleTemplate

use of com.mitchellbosecke.pebble.template.PebbleTemplate in project symja_android_library by axkr.

the class HistogramTrace method asJavascript.

@Override
public String asJavascript(int i) {
    Writer writer = new StringWriter();
    PebbleTemplate compiledTemplate;
    try {
        compiledTemplate = engine.getTemplate("trace_template.html");
        compiledTemplate.evaluate(writer, getContext(i));
    } catch (PebbleException e) {
        throw new IllegalStateException(e);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return writer.toString();
}
Also used : PebbleException(com.mitchellbosecke.pebble.error.PebbleException) StringWriter(java.io.StringWriter) PebbleTemplate(com.mitchellbosecke.pebble.template.PebbleTemplate) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) StringWriter(java.io.StringWriter) Writer(java.io.Writer)

Example 8 with PebbleTemplate

use of com.mitchellbosecke.pebble.template.PebbleTemplate in project symja_android_library by axkr.

the class Component method asJavascript.

protected String asJavascript(String filename) {
    Writer writer = new StringWriter();
    PebbleTemplate compiledTemplate;
    try {
        compiledTemplate = getEngine().getTemplate(filename);
        compiledTemplate.evaluate(writer, getContext());
    } catch (PebbleException e) {
        throw new IllegalStateException(e);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return writer.toString();
}
Also used : PebbleException(com.mitchellbosecke.pebble.error.PebbleException) StringWriter(java.io.StringWriter) PebbleTemplate(com.mitchellbosecke.pebble.template.PebbleTemplate) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) StringWriter(java.io.StringWriter) Writer(java.io.Writer)

Example 9 with PebbleTemplate

use of com.mitchellbosecke.pebble.template.PebbleTemplate in project symja_android_library by axkr.

the class Layout method asJavascript.

public String asJavascript() {
    Writer writer = new StringWriter();
    PebbleTemplate compiledTemplate;
    try {
        compiledTemplate = engine.getTemplate("layout_template.html");
        compiledTemplate.evaluate(writer, getContext());
    } catch (PebbleException e) {
        throw new IllegalStateException(e);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return writer.toString();
}
Also used : PebbleException(com.mitchellbosecke.pebble.error.PebbleException) StringWriter(java.io.StringWriter) PebbleTemplate(com.mitchellbosecke.pebble.template.PebbleTemplate) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) StringWriter(java.io.StringWriter) Writer(java.io.Writer)

Example 10 with PebbleTemplate

use of com.mitchellbosecke.pebble.template.PebbleTemplate in project osiostatsgenerator by piyush1594.

the class StatsGenerator method printHTMLStats.

private static String printHTMLStats() throws PebbleException, IOException {
    PebbleEngine engine = new PebbleEngine.Builder().build();
    PebbleTemplate compiledTemplate = engine.getTemplate("templates/stats_table.html");
    Writer writer = new StringWriter();
    Map<String, Object> context = new HashMap<String, Object>();
    context.put("websiteTitle", "OpenShift.io GitHub Stats");
    context.put("stats", Stats);
    context.put("now", Calendar.getInstance().getTime());
    compiledTemplate.evaluate(writer, context);
    String output = writer.toString();
    return output;
}
Also used : StringWriter(java.io.StringWriter) PebbleTemplate(com.mitchellbosecke.pebble.template.PebbleTemplate) StringWriter(java.io.StringWriter) Writer(java.io.Writer) PebbleEngine(com.mitchellbosecke.pebble.PebbleEngine)

Aggregations

PebbleTemplate (com.mitchellbosecke.pebble.template.PebbleTemplate)20 StringWriter (java.io.StringWriter)19 Writer (java.io.Writer)17 PebbleException (com.mitchellbosecke.pebble.error.PebbleException)15 IOException (java.io.IOException)15 UncheckedIOException (java.io.UncheckedIOException)15 HashMap (java.util.HashMap)2 Utils.dataAsString (tech.tablesaw.plotly.Utils.dataAsString)2 PebbleEngine (com.mitchellbosecke.pebble.PebbleEngine)1 LanguageHeader (io.vertx.ext.web.LanguageHeader)1 Locale (java.util.Locale)1 Map (java.util.Map)1