private String buildDefafultEmailSubject(TaskData taskData,Task task){ Map<String, Object> vars = new HashMap<String, Object>(); vars.put("taskName", task.getName()); vars.put("processId", taskData.getProcessId()); String body = (String) TemplateRuntime.eval(defaultEmailSubject, vars); return body; } }
private String buildDefafultEmailBody(TaskData taskData,Task task){ Map<String, Object> vars = new HashMap<String, Object>(); vars.put("taskName", task.getName()); vars.put("taskId", task.getId()); vars.put("deploymentId", taskData.getDeploymentId()); vars.put("processId", taskData.getProcessId()); vars.put("processInstanceId", taskData.getProcessInstanceId()); String body = (String) TemplateRuntime.eval(defaultEmailBody, vars); return body; }
public void printPrompt() { if (!multi) { multiIndentSize = (prompt = String.valueOf(TemplateRuntime.eval(env.get("$PROMPT"), variables))).length(); out.append(prompt); } else { out.append(">").append(indent((multiIndentSize - 1) + (depth * 4))); } }
private String templateEips(List<EipModel> models, long deprecated) throws MojoExecutionException { try { String template = loadText(UpdateReadmeMojo.class.getClassLoader().getResourceAsStream("readme-eips.mvel")); Map<String, Object> map = new HashMap<>(); map.put("eips", models); map.put("numberOfDeprecated", deprecated); String out = (String) TemplateRuntime.eval(template, map); return out; } catch (Exception e) { throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e); } }
private String templateAutoConfigurationOptions(List<SpringBootAutoConfigureOptionModel> options) throws MojoExecutionException { try { String template = loadText(UpdateSpringBootAutoConfigurationReadmeMojo.class.getClassLoader().getResourceAsStream("spring-boot-auto-configure-options.mvel")); String out = (String) TemplateRuntime.eval(template, options); return out; } catch (Exception e) { throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e); } }
public String transform(String input) { String path = CommonUtils.removeKeyword(input); try { path = (String) TemplateRuntime.eval(path, map); } catch (RuntimeException nothandled) { // do nothing, gracefully fallback to // the default, unparsed path } return path; } });
public static void main(String[] args) { String template = "My List of things @foreach{item:things}@{item.toUpperCase()}@end{', '}"; Map<String, Object> vars = new HashMap<String, Object>(); Set<String> things = new HashSet<String>(); things.add("soap"); things.add("siphon"); things.add("powder"); vars.put("name", "Mike"); vars.put("things", things); System.out.println(TemplateRuntime.eval(template, vars)); }
public void testTemplateFile() { String s = (String) TemplateRuntime.eval(new File("src/test/java/org/mvel2/tests/templates/templateIfTest.mv"), base, new MapVariableResolverFactory(map), null); System.out.println(s); }
public void testEscaping() { String template = "@@{'foo'}ABC"; assertEquals("@{'foo'}ABC", TemplateRuntime.eval(template, new Object())); }
/** * Integration of old tests */ public void testPassThru2() { assertEquals("foo@bar.com", TemplateRuntime.eval("foo@bar.com", map)); }
public void testIteration1() { List<String> list = new ArrayList<String>(); list.add("a1"); list.add("a2"); list.add("a3"); String template = "@foreach{item : list}a@end{}"; Map map = new HashMap(); map.put("list", list); String r = (String) TemplateRuntime.eval(template, map); System.out.println("r: " + r); assertEquals("aaa", r); }
public void testTemplateMVEL220() { Map<String, Object> vars = setupVarsMVEL220(); System.out.println("Templates====================="); for (String expr : templateTestCasesMVEL220) { System.out.println("Templating '" + expr + "': ......"); Object ret = TemplateRuntime.eval(expr, vars); System.out.println("'" + expr + " ' = " + ret.toString()); assertNotNull(ret); } System.out.println("Templates====================="); }
public void testIteration4() { Folder f = new Folder("a1", null); String template = "@foreach{item : f.children}a@end{}"; Map map = new HashMap(); map.put("f", f); String r = (String) TemplateRuntime.eval(template, map); System.out.println("r: " + r); assertEquals("aaa", r); }
public void testTemplateMVEL219() { Map<String, Object> vars = setupVarsMVEL219(); for (String expr : templateTestCasesMVEL219) { System.out.println("Templating '" + expr + "': ......"); Object ret = TemplateRuntime.eval(expr, vars); System.out.println("'" + expr + " ' = " + ret.toString()); assertNotNull(ret); } }
public void testImportsInTemplate() { String template = "@code{import java.util.HashMap; i = 10;}_____________@code{new HashMap().toString() + i}"; Map map = new HashMap(); Object result = TemplateRuntime.eval(template, map); assertNotNull("result cannot be null", result); assertEquals("result did not return string", String.class, result.getClass()); }
public Object eval(TemplateRuntime runtime, TemplateOutputStream appender, Object ctx, VariableResolverFactory factory) { String file = MVEL.eval(contents, includeStart, includeOffset, ctx, factory, String.class); if (preOffset != 0) { MVEL.eval(contents, preStart, preOffset, ctx, factory); } if (next != null) { return next.eval(runtime, appender.append(String.valueOf(TemplateRuntime.eval(readInFile(runtime, file), ctx, factory))), ctx, factory); } else { return appender.append(String.valueOf(MVEL.eval(readInFile(runtime, file), ctx, factory))); } }
public void testIteration3() { Folder f = new Folder("a1", null); List<Page> list = f.getChildren(); String template = "@foreach{item : list}a@end{}"; Map map = new HashMap(); map.put("list", list); String r = (String) TemplateRuntime.eval(template, map); System.out.println("r: " + r); assertEquals("aaa", r); }
public void testMVEL197() { Map<String, Object> context = new HashMap<String, Object>(); Object[] args = new Object[1]; TestMVEL197 test = new TestMVEL197(); test.setName1("name1"); test.setName2("name2"); args[0] = test; context.put("args", args); String template = "${(args[0].name1=='name1'&&args[0].name2=='name2')?'a':'b'}"; Object value = TemplateRuntime.eval(template, context); assertEquals("a", value); }
public void testInclusionOfNamedTemplate() { SimpleTemplateRegistry registry = new SimpleTemplateRegistry(); registry.addNamedTemplate("footemplate", compileTemplate("@{_foo_}@{_bar_}")); registry.addNamedTemplate("bartemplate", compileTemplate("@{_bar_}@{_foo_}")); String s = "@includeNamed{'footemplate'} :: @includeNamed{'bartemplate'}"; assertEquals("FooBar :: BarFoo", TemplateRuntime.eval(s, map, registry)); }