what does browser do when it encounters – mu is too short Nov 10 '12 at 19:11

2 Answers2

2

The browser ignores it -- it cannot try and execute the script, since it doesn't recognize the type.

And you can't use a div, because the template is often not valid HTML (eg, the underscore templating syntax <%= modelproperty %>.

McGarnagle
  • 96,448
  • 30
  • 213
  • 255
1

Browser simply ignores such tags. It's useful to put templates inside such tags, because you don't need to encode HTML symbols like <, >, & for example:

<script type="text/template">
    <% for(var i = 0; i < 10; i++) { %>
        // do something
    <% } %>
</script>

Inside the hidden div you should write something like this:

<script type="text/template">
    &lt;% for(var i = 0; i &lt; 10; i++) { %&gt;
        // do something
    &lt;% } %&gt;
</script>
Inferpse
  • 4,077
  • 1
  • 27
  • 37