Split template parsing from template generation.

Moved function for transforming template parse tree into AST from
template parser into template.c.

Added methods to syntax mode for merging text of descendant nodes into
the parent node.