title: Replace multiple instances of the same value in a javascript template
body: <p>I have a javascript template were I want to replace a set value in multiple locations throughout the template, however in my current code only the first instance of the value placeholder is changing.</p>
  
  <p>How do I replace all {{color}} placeholders with the same value?</p>
  
  <p>My template:</p>
  
  <pre><code>&lt;script type="text/template" id="styleTemplate"&gt;    
  .item {
      color: {{color}};
      border-color:{{color}};
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>My JS:</p>
  
  <pre><code>var thisColor = "#000";
  var template = $("#styleTemplate").html();
  $('#styleTarget').html(template.replace("{{color}}",thisColor));
  </code></pre>
  
  <p>The result:</p>
  
  <pre><code>.item {
      color: #000;
      border-color:{{color}};
  }
  </code></pre>