scalate/scalate — pull request #44 by rstrickland (2012-12-20 19:38:25+00:00)
Title: Added support for pre-processed includes

This makes it possible to do an include prior to compilation of the template, so things like global variables or other bits of included code can be referenced. While it's possible that at some point other pre-processed directives might be desired, I took the KISS approach for this and implemented only an include directive. It should be relatively straightforward to make this generic if any others need to be implemented in the future.

It works by placing a directive such as the following in any template (regardless of format):

```
@@include("/path/to/file")
```

Templates may have any number of includes, and they can appear anywhere in the template. They can also be nested, such that an included template may also have includes inside it.

The primary difference in functionality from the existing include/render methods is that it's possible to do something like this:

globals.scaml:

```
- lazy val name = "Robbie"
- lazy val address = "123 Main St."
```

template.scaml:

```
@@include("globals.scaml")
The address for #{name} is #{address}
```

The current mechanism using ScalatePackage requires a recompile of the application, whereas this method only requires recompiling the templates. The latter is much preferable for our use case, and I suspect others may also benefit.