fixed template_from_string when the template includes or extends other ones

This should fix #1134