[whatwg] <script> content restrictions vis-a-vis HTML template data blocks

Re: the "Restrictions for contents of script elements" (4.12.1.2):

Consider <script> elements containing data blocks. It's useful to embed 
templates in these; HTML templates for example. When embedding HTML 
templates, it would be onerous to have to either omit comments or implement 
an escaping / unescaping regimen. The specification suggests 'to always 
escape "<!--" as "<\!--"', which isn't too bad for JavaScript, but would be 
a hassle for HTML templates.

The following examples illustrate my interpretation of the requirements for 
<script> content. Is this correct?

Non-conforming (does not match the "outer" production before "comment-open" 
/ after "comment-close" / or both):

<script type="text/plain"><!-- a --></script>

<script type="text/plain">
<!-- a --></script>

<script type="text/plain"><!-- a -->
</script>


Conforming (newline characters satisfy the "outer" production in both 
positions):

<script type="text/plain">
<!-- a -->
</script>


Conforming (space characters satisfy the "outer" production in both 
positions):

<script type="text/plain"> <!-- a --> </script> 

Received on Wednesday, 5 November 2014 19:48:21 UTC