What are the main differences between StringTemplate and FreeMarker?

I designed ST to build jGuru after getting sick of the “code in template” model of JSP. Velocity and friends (i.e., every other engine i think) give you more power than you need. I used basically four features to build jGuru.com (as described in paper). More features are unnecessary and lead you to entangle your … Read more

A url resource that is a dot (%2E)

It’s actually not really clearly stated in the standard (RFC 3986) whether a percent-encoded version of . or .. is supposed to have the same this-folder/up-a-folder meaning as the unescaped version. Section 3.3 only talks about “The path segments . and ..”, without clarifying whether they match . and .. before or after pct-encoding. Personally … Read more

Setting freemarker template from classpath

this is what ended up working for me: freemarkerConfiguration = new Configuration(Configuration.VERSION_2_3_28); freemarkerConfiguration.setClassForTemplateLoading(this.getClass(), “https://stackoverflow.com/”); Template freemarkerTemplate = freemarkerConfiguration.getTemplate(“email/vendor.tpl”);

How to output ${expression} in Freemarker without it being interpreted?

This should print ${person.name}: ${r”${person.name}”} From the freemarker docs A special kind of string literals is the raw string literals. In raw string literals, backslash and ${ have no special meaning, they are considered as plain characters. To indicate that a string literal is a raw string literal, you have to put an r directly … Read more

Passing a List of Objects to Freemarker and then Looping

Is “jobs” really a collection? Please post a snippet of code where you are creating and processing your template. I just wrote a quick test to check: public void testFreeMarker() throws Exception { List<Invoice> invoices = Arrays.asList( new Invoice( “note1”, “amount1” ), new Invoice( “note2”, “amount2” ) ); Map<String, Object> root = new HashMap<String, Object>(); … Read more