LoadingStringTemplatesFromUrl - danielbodart/webfabric GitHub Wiki

Introduction

StringTemplate has various different ways to support loading templates but does not support loading loose templates from any arbitrary base Url. This can very useful when inside an unexpanded War/Jar or if you just wish to decouple yourself from the file system.

Details

All you need to do is instantiate UrlStringTemplateGroup with a name and the base Url when templates should be loaded from.

UrlStringTemplateGroup group = new UrlStringTemplateGroup("webfabric", "http://webfabric.org/templates/");
StringTemplate template = group.getInstanceOf("home")

This would end up doing a HTTP GET request to "http://webfabric.org/templates/home.st" honouring any caching directives set by the server.