use of com.mitchellbosecke.pebble.template.PebbleTemplate in project symja_android_library by axkr.
the class Histogram2DTrace 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();
}
use of com.mitchellbosecke.pebble.template.PebbleTemplate in project symja_android_library by axkr.
the class PieTrace method asJavascript.
@Override
public String asJavascript(int i) {
Writer writer = new StringWriter();
PebbleTemplate compiledTemplate;
try {
compiledTemplate = engine.getTemplate("pie_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();
}
use of com.mitchellbosecke.pebble.template.PebbleTemplate in project symja_android_library by axkr.
the class Figure method asJavascript.
public String asJavascript(String divName) {
Writer writer = new StringWriter();
PebbleTemplate compiledTemplate;
buildContext(divName);
try {
compiledTemplate = engine.getTemplate("figure_template.html");
compiledTemplate.evaluate(writer, getContext());
} catch (PebbleException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return writer.toString();
}
use of com.mitchellbosecke.pebble.template.PebbleTemplate in project symja_android_library by axkr.
the class HeatmapTrace 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());
} catch (PebbleException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return writer.toString();
}
use of com.mitchellbosecke.pebble.template.PebbleTemplate in project symja_android_library by axkr.
the class IOFunctions method templateApply.
/**
* Render the template with the assigned context variable strings.
*
* @param templateString the template which should be rendered
* @param outputWriter use {@link Writer#toString()} to get the rendered result
* @param context the assigned variables which should be rendered in the template
* @throws IOException
*/
private static void templateApply(String templateString, Writer outputWriter, Map<String, Object> context) throws IOException {
PebbleCache<Object, PebbleTemplate> cache = PEBBLE_ENGINE.getTemplateCache();
PebbleTemplate template = cache.computeIfAbsent(templateString, x -> templateCompile(templateString));
template.evaluate(outputWriter, context);
}
Aggregations