Correct handling of the <template> tag content fragments. Fixes #942