Posted By

inreflection7 on 11/22/12


js template your own roll

Versions (?)

Safe replace {{some_var}} in JS strings

 / Published in: JavaScript

For those moments of weakness when .replace() looks like a good idea...

  1. // Bad example but you get where I'm going with this.
  3. my_string = "{{some_var}} weather out today";
  5. my_string.replace(/\{\{(.+?)\}\}/g, 'great');

Report this snippet  

You need to login to post a comment.