JSPM

es6-template-regex

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15269
  • Score
    100M100P100Q139169F
  • License MIT

Regular expression for matching es6 template delimiters in a string.

Package Exports

  • es6-template-regex

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (es6-template-regex) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

es6-template-regex NPM version

Regular expression for matching es6 template delimiters in a string.

Install

Install with npm

$ npm i es6-template-regex --save

Usage

The top-level export of this module is a function:

var re = require('es6-template-regex');

function interpolate(str, data) {
  return str.replace(re(), function(m, prop) {
    return data[prop] || prop;
  });
}

var str = 'foo ${bar} baz ${quux}';
var data = {bar: 'AAA', quux: 'BBB'};
interpolate(str, data);
//=> 'foo AAA baz BBB'

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on August 10, 2015.