Transform Original Value?
Hi,
I'd like to transform the original value e.g.
"primary": {
"comment": "Primary Border color.",
"value": "#CF4500",
"isSource": true,
"original": {
"comment": "Primary Border color.",
**"value": "{color.brand.primary.value}"**
},
from {color.brand.primary.value} to COLOR BRAND PRIMARY
Is this possible to do using a transform e.g.
module.exports = {
type: `value`,
matcher: (token) =>
token.attributes.category === `color`,
transformer: function (token) {
const value = token.original.value;
return `${value.toUpperCase()}`;
},
};
Thanks,
Emma
Thank you for the question! Sorry we didn't get to this sooner, I was on vacation and was supposed to do it before I left :/
The code you have should work. You can reference the token's original value in a transform. Whatever you return from the transformer function will be written to the value of the token. If you are trying to write to original.value that is not possible because we intended for the original object to be a clean copy of the original data and for it to not be transformed. If that is what you are trying to do could give a bit more context into the problem you are trying to solve by overwriting original.value and maybe there is another solution.