substitute.js 361 B

12345678910111213
  1. function substitute(str, o) {
  2. if (!str || !o) {
  3. return str;
  4. }
  5. return str.replace(/\\?\{([^{}]+)\}/g, function (match, name) {
  6. if (match.charAt(0) === '\\') {
  7. return match.slice(1);
  8. }
  9. return (o[name] === undefined) ? '' : o[name];
  10. });
  11. }
  12. export default substitute;
  13. //# sourceMappingURL=substitute.js.map