Closed dzikoysk closed 8 months ago
I'm currently making research around some existing template engines and jte looks quite promising. One of my requirements is the ability to replace a custom tag with some other content, e.g.:
<Custom> <p>Text</p> </Custom>
with:
<article> <section> <p>Text</p> </section </article>
I was playing a little bit with html interceptor:
templatingEngine.setHtmlTags("custom"); templatingEngine.setHtmlInterceptor(new HtmlInterceptor() { @Override public void onHtmlTagOpened(String name, Map<String, Object> attributes, TemplateOutput output) { if (name.equals("Custom")) { output.writeUserContent("abc"); } } @Override public void onHtmlTagClosed(String name, TemplateOutput output) { if (name.equals("Custom")) { output.writeUserContent("cdf"); } }
but this API seems to be a little too simple for that use case. I wonder if there's some other way to achieve this kind of results.
Not really.
The idiomatic jte way to do this is to call another template, e.g.
@template.custom(body = @` <p>Text</p> `)
I'm currently making research around some existing template engines and jte looks quite promising. One of my requirements is the ability to replace a custom tag with some other content, e.g.:
with:
I was playing a little bit with html interceptor:
but this API seems to be a little too simple for that use case. I wonder if there's some other way to achieve this kind of results.