variables à l'intérieur du modèle underscore.js

Comment définir des variables à l'intérieur d'un underscore.js modèle pour une application construite avec backbone.js? Je veux juste créer réutilisables traitées cordes. Aussi, peut underscore.js's de fonctions intégrées comme _.escape être utilisés pour traiter ces variables?

<script type="text/html" id="templateresults">

<p><%= encodeURIComponent(title) %></p> // this works

//try 1:
var encodedTitle = encodeURIComponent(title); //shows up as regular text
<p>'+encodedTitle+'</p> // this doesn't work and shows up as regular text

//try 2:
<% var encodedTitle = encodeURIComponent(title); %> //nothing shows up
<p><% '+encodedTitle+' %></p> // nothing shows up

</script>

title est un JSON élément (chaîne de texte).

Codé de sortie: This%20is%20a%20Sample%20Title
Sortie régulière: This is a Sample Title

source d'informationauteur Steve