Have a look at D, its metaprogramming facilities are really something.
In particular string mixins will do what you want; they will also do much more, like for instance include external files written in domain specific languages and compile them in native D code; all this is done by the compiler, using language facilities, without external tools.
(These is not some theoretically cool feature; it's used in real world code, like dproto, which compiles protobuf definitions into native code, or HTML templating engines which compile templates to the equivalent of Java servlets)
In particular string mixins will do what you want; they will also do much more, like for instance include external files written in domain specific languages and compile them in native D code; all this is done by the compiler, using language facilities, without external tools.
(These is not some theoretically cool feature; it's used in real world code, like dproto, which compiles protobuf definitions into native code, or HTML templating engines which compile templates to the equivalent of Java servlets)