I recently went to myspace website to check out how they were doing :) on their HTML code, there's this piece of inline jQuery within their HTML code:
<script type="text/html" id="AutoCompleteResultsTemplate">
<![CDATA[
<* var q = MySpace.Search.Utils.TranslateSpecialChars(this.query); *>
<span class="suggestions">
<*=this.suggestionResource *>
</span>
<ul>
<* jQuery.each(this.results, function(i,v) {
jQuery.each(v, function(j, d) {
*>
<li data-query="<*=d.displayText *>" data-url="<*= d.url *>">
<span class="type"><*=d.type *></span>
<*=MySpace.Search.Utils.HighlightCharacters(d.displayText, q) *>
</li>
<* });
}); *>
<li class="last" data-query="<*=this.query *>" data-url="<*= this.allResultUrl *>">
<span class="type"><*=this.allResultText *></span>
<*=this.searchResource *> '<*= this.query *>'
</li>
</ul>
<iframe></iframe>
]]>
</script>
I never used CDATA before, but I know it's used for XHTML (so that when you have inline javascript, it still validates)while myspace is currently using HTML 5. Is there any particular reason they use CDATA? thanks in advance.