silverstripe/sapphire — pull request #1793 by Zauberfisch (2013-04-22 18:59:26+00:00)
Title: API: made more robust SSTemplateParser->includeDebuggingComments()

includeDebuggingComments() was breaking HTML in some edge cases

if you use something like this (eg from html5 boilerplate):

the parser would put the comment after each `` tag, which would make the HTML invalid (comment inside a comment)

the parser now tries to insert it right after the doctype if one is available, or after the `` tag that is not inside a comment

Tests for several edge cases have been included:
- no doctype
- html4 doctype
- html5 doctype & IE `` tag
- no doctype & IE `` tag

The code & tests for the no doctype cases can be considered overdoing it.
At the time of sending this pull request it produces valid output in almost any possible case, question is, do we care about those cases where no doctype but `` is given?

the only possible case that is not covered in this pull request is #1792