Replacing Soy templates with Apache Freemarker - can you compile n number of templates into a single file?
17:16 26 Mar 2026

We're currently using Soy templates (aka Google Closure templates) in our Java project. A few years ago I collected all of the individual soy templates and concatenated them into a single file for ease of compilation. Now when we need one, we can pluck out a single template for the compiled file with ease, passing in the desired context.

Now we're looking to migrate to Apache Freemarker, and I want to find out if this same approach is an option in that system. A cursory glance seems to indicate that it isn't, but I wanted to ask people who might be more familiar with Freemarker to confirm. It's not a huge deal if it isn't, in part because Freemarker seems to have a better and easier time working with single templates. But I love the idea of having all of it compiled and ready to go.

Note that Soy templates accomplish this by wrapping each template within a template block:

{template userGroupChangedSubject}
{@param userGroup : string}
{$userGroup} user group details updated
{/template}
freemarker