views:

60

answers:

2

I was checking out the source on an html page and came across this

<script id="searchItemTemplate" type="text/html"> 
    <# var rows = Math.floor((Model.RecordsPerPage - 1) / 3 + 1);
       for (var i = 0; i < rows; ++i){
        var startIdx = i * 3;
        var endIdx = startIdx + 3;
    #>
//etc .... 
</script>

I have never seen this before. What is script type="text/html". I don't know if it makes a difference but this was on a .aspx page.

Is this some sort of place holder to be parsed and eval() later?
Does anyone know what this is?
Can someone who has used this method explain the benefits?

+3  A: 

Script elements that have an unknown content-type are simply ignored, in this case, the browser doesn't know how to execute a text/html script.

It's a common technique used by some JavaScript templating engines.

See also:

CMS
BTW, [Processing.js](http://processingjs.org/) also uses this technique.
CMS
+2  A: 
Pointy