Babel plugin that will replace data element tokens (eg: {{some_data_element}}) with valid JavaScript.

Usage no npm install needed!

<script type="module">
  import adobeReactorBabelPluginReplaceTokensEdge from 'https://cdn.skypack.dev/@adobe/reactor-babel-plugin-replace-tokens-edge';



Babel plugin that will replace data element tokens (eg: getDataElementValue(reactorXXX)) with valid JavaScript.

There is an intermediate step that needs to take place before the plugin can be executed. The data element tokens need to be converted to a function call. Example: If you have the token {{name}} in your code, then it needs to become getDataElementValue(reactorXXX). Notice there are no quotes surrounding the name. This is because if the replacement takes place inside a code surrounded by quotes, a JS error will be thrown by Babel. Also the token name needs to be hex encoded so that no character will make the function call invalid. Then the babel plugin can be executed. It will take care of adding quotes around the name. In our debug command we use sed to make this transformation. If you use webpack, you need to do the replacement before the babel plugin is executed.


You can install dependencies by running:

npm install


You have a container fixture located in the folder test/fixtures/container.js. You can change the content of the fixture in order to see new results.

You can run:

npm run debug

and you will see the result with plugin changes applied in stdout.


Contributions are welcomed! Read the Contributing Guide for more information.


This project is licensed under the Apache V2 License. See LICENSE for more information.