N
N
Nick Smith2018-03-05 12:50:36
Java
Nick Smith, 2018-03-05 12:50:36

Is there a templating engine with the ability to parse back into an object?

Here is an example of the desired API

class TemplateEngineTest {
    private final static String TEMPLATE = "<test>${testName}</test>";

    private Object templateEngine;

    public void testEngine() {
        TestDtoObject dto = new TestDtoObject();
        String renderedTemplate = templateEngine.render(TEMPLATE, dto);
        assert renderedTemplate.equals("<test>myTestName</test>");

        TestDtoObject resultDtr = templateEngine.unrender(TEMPLATE, renderedTemplate, TestDtoObject.class);
        assert dto.equals(resultDtr);
    }

    static class TestDtoObject {
        String testName = "myTestName";
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
al_gon, 2018-03-05
@al_gon

https://www.mkyong.com/java/jaxb-hello-world-example/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question