项目原始demo,不改动
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
To repozytorium jest zarchiwizowane. Możesz wyświetlać pliki i je sklonować, ale nie możesz do niego przepychać zmian lub otwierać zgłoszeń/Pull Requestów.
 
 
 
 

29 wiersze
763 B

  1. /**
  2. * @fileoverview Interpolate keys from an object into a string with {{ }} markers.
  3. * @author Jed Fox
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Public Interface
  8. //------------------------------------------------------------------------------
  9. module.exports = (text, data) => {
  10. if (!data) {
  11. return text;
  12. }
  13. // Substitution content for any {{ }} markers.
  14. return text.replace(/\{\{([^{}]+?)\}\}/g, (fullMatch, termWithWhitespace) => {
  15. const term = termWithWhitespace.trim();
  16. if (term in data) {
  17. return data[term];
  18. }
  19. // Preserve old behavior: If parameter name not provided, don't replace it.
  20. return fullMatch;
  21. });
  22. };