TemplateEngine { public String getValue(String template) { StringBuilder builder = new StringBuilder(); Expression[] expressions = ExpressionParser.parseExpressions(template, context, expressionPrefix, expressionSuffix); for (Expression expression : expressions) { builder.append(expression.getValue(context)); } return builder.toString(); } protected  TemplateEngine(); String getExpressionPrefix(); void setExpressionPrefix(String expressionPrefix); String getExpressionSuffix(); void setExpressionSuffix(String expressionSuffix); EvaluationContext getContext(); String getValue(String template); static final String DEFAULT_EXPRESSION_PREFIX; static final String DEFAULT_EXPRESSION_SUFFIX; }
@Test public void testContextlessTemplate() { String template = "{\"signedAt\": \"{{ now() }}\", \"fullName\": \"Laurent Broudoux\", \"email\": \"laurent@microcks.io\", \"age\": 41} \n"; TemplateEngine engine = TemplateEngineFactory.getTemplateEngine(); String content = null; try { content = engine.getValue(template); System.err.println("Content: " + content); } catch (Throwable t) { fail("Contextless template should not fail."); } assertTrue(content.startsWith("{\"signedAt\": \"1")); }