daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Oct 21st, 2018 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // By default, Underscore uses ERB-style template delimiters, change the
  2. // following template settings to use alternative delimiters.
  3. _.templateSettings = {
  4. evaluate : /<%([\s\S]+?)%>/g,
  5. interpolate : /<%=([\s\S]+?)%>/g,
  6. escape : /<%-([\s\S]+?)%>/g
  7. };
  8.  
  9. // JavaScript micro-templating, similar to John Resig's implementation.
  10. // Underscore templating handles arbitrary delimiters, preserves whitespace,
  11. // and correctly escapes quotes within interpolated code.
  12. _.template = function(str, data) {
  13. var c = _.templateSettings;
  14. var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
  15. 'with(obj||{}){__p.push(\'' +
  16. str.replace(/\\/g, '\\\\')
  17. .replace(/'/g, "\\'")
  18. .replace(c.escape, function(match, code) {
  19. return "',_.escape(" + code.replace(/\\'/g, "'") + "),'";
  20. })
  21. .replace(c.interpolate, function(match, code) {
  22. return "'," + code.replace(/\\'/g, "'") + ",'";
  23. })
  24. .replace(c.evaluate || null, function(match, code) {
  25. return "');" + code.replace(/\\'/g, "'")
  26. .replace(/[\r\n\t]/g, ' ') + "__p.push('";
  27. })
  28. .replace(/\r/g, '\\r')
  29. .replace(/\n/g, '\\n')
  30. .replace(/\t/g, '\\t')
  31. + "');}return __p.join('');";
  32. var func = new Function('obj', tmpl);
  33. return data ? func(data) : func;
  34. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top