ServerSideIncludesInStringTemplate - danielbodart/webfabric GitHub Wiki

Introduction

StringTemplate is a pure templating language with no dependencies on running in a web server but if you are using it in a web server wouldn't it be great if you could do server side mashups / includes?

That's what the PageMap class allows you to do. Using the StringTemplate support for the Map interface you can provide a Url or path to as the key and the result will be a parsed HTMLPage.

Example

StringTemplate template = new StringTemplate("$include.(url).title$");
template.setAttribute("include",  new PageMap());
template.setAttribute("url", "http://www.goggle.co.uk/");

assertEquals("Google", template.toString());