Minor template compilation changes

Inherit the defined variables in subtemplates, such that you can build a truly inherited template and are able to reuse HTML snippets. Also saved some bytes in the regexes.