How to use the sprintf-js.sprintf.format function in sprintf-js

To help you get started, we’ve selected a few sprintf-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NetEaseGame / Sentry / src / sentry / static / sentry / app / locale.jsx View on Github external
} else {
        arg = args[cursor++];
      }

      // this points to a react element!
      if (React.isValidElement(arg)) {
        rv.push(React.cloneElement(arg, {key: idx}));
      // not a react element, fuck around with it so that sprintf.format
      // can format it for us.  We make sure match[2] is null so that we
      // do not go down the object path, and we set match[1] to the first
      // index and then pass an array with two items in.
      } else {
        match[2] = null;
        match[1] = 1;
        rv.push(<span>
          {sprintf.format([match], [null, arg])}
        </span>);
      }
    }
  });
github getsentry / sentry / src / sentry / static / sentry / app / locale.jsx View on Github external
arg = args[parseInt(match[1], 10) - 1];
      } else {
        arg = args[cursor++];
      }

      // this points to a react element!
      if (React.isValidElement(arg)) {
        rv.push(React.cloneElement(arg, {key: idx}));
        // not a react element, fuck around with it so that sprintf.format
        // can format it for us.  We make sure match[2] is null so that we
        // do not go down the object path, and we set match[1] to the first
        // index and then pass an array with two items in.
      } else {
        match[2] = null;
        match[1] = 1;
        rv.push(<span>{sprintf.format([match], [null, arg])}</span>);
      }
    }
  });
github getsentry / sentry / src / sentry / static / sentry / app / locale.tsx View on Github external
arg = args[parseInt(match[1], 10) - 1];
    } else {
      arg = args[cursor++];
    }

    // this points to a react element!
    if (React.isValidElement(arg)) {
      nodes.push(React.cloneElement(arg, {key: idx}));
    } else {
      // not a react element, fuck around with it so that sprintf.format
      // can format it for us.  We make sure match[2] is null so that we
      // do not go down the object path, and we set match[1] to the first
      // index and then pass an array with two items in.
      match[2] = null;
      match[1] = 1;
      nodes.push(<span>{sprintf.format([match], [null, arg])}</span>);
    }
  });
github apache / incubator-superset / superset / assets / src / locales.jsx View on Github external
} else {
      let arg = null;
      if (match[2]) {
        arg = args[0][match[2][0]];
      } else if (match[1]) {
        arg = args[parseInt(match[1], 10) - 1];
      } else {
        arg = args[cursor++];
      }
      if (React.isValidElement(arg)) {
        rv.push(React.cloneElement(arg, { key: idx }));
      } else {
        cpoyMatch[2] = null;
        cpoyMatch[1] = 1;
        rv.push(<span>
          {sprintf.format([cpoyMatch], [null, arg])}
        </span>);
      }
    }
  });
  return rv;

sprintf-js

JavaScript sprintf implementation

BSD-3-Clause
Latest version published 8 months ago

Package Health Score

76 / 100
Full package analysis

Similar packages