pizza247
pizza247

Reputation: 3897

use a script tag for a javascript template instead of a string

So I've seen handlebars templates do this:

<script id="some-template" type="text/x-handlebars-template">  </script>

and am wondering if there's a way to use underscore.js templates like this. It would be really nice to have my templates in markup instead of sitting inside a string.

Upvotes: 0

Views: 126

Answers (1)

Steve H.
Steve H.

Reputation: 6947

Sure, you can do this easily.

var templateText= document.getElementById('some-template').innerHTML;

Upvotes: 2

Related Questions