$($('.templates').html())
will struggle if the inner HTML of the "templates" class starts with a space, so you'd need $($('.templates').html().trim())
instead. You'll end up in further trouble though because the inner HTML of your script tag doesn't have a root node, so you'd instead need something like:
<script type="text/x-templates" class="templates">
<div>
<div class="template1">temp1</div>
<div class="template2">temp2</div>
...
</div>
</script>
You could then get the HTML of template1 with something like:
var templatesCollection = $($(".templates").html().trim());
alert(templatesCollection.children(".template1").html());
But, all this said, why not put each template in its own script tag with an ID? (Class doesn't make much sense unless you're planning on having more than one instance, and in a templating scenario I would assume that's not what you want.)
So something more like:
<script type="text/html" id="template1">
<div>temp1</div>
</script>
And then a very simple selector: $("#template1").html()