Original code of templates
Code style
Improved code

- Allow nested templates;
- Escape test nodes;
- Escape back slash and apos.