simpledoT.js 789 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Licensed Materials - Property of IBM
  3. *
  4. * IBM Cognos Products: SHARE
  5. *
  6. * (C) Copyright IBM Corp. 2015
  7. *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure
  9. * restricted by GSA ADP Schedule Contract with IBM Corp.
  10. */
  11. define(["doT"], function(dot) {
  12. var simpledot = dot;
  13. simpledot.NOT_REPLACED = "__NOT_REPLACED__";
  14. simpledot.options = {
  15. verbose: false
  16. };
  17. simpledot.simpleTemplate = function(template) {
  18. var templateToProcess = template;
  19. if (simpledot.options.verbose) {
  20. templateToProcess = template.replace(/\{\{(=[\s\S]+?(\}?)+)\}\}/g,"{{$1 || '" + simpledot.NOT_REPLACED + "($1)'}}");
  21. }
  22. return dot.template(templateToProcess);
  23. };
  24. return simpledot;
  25. });