Fix substitute function for HTML entities & disable it for templates namespace