You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nix-in-node/src/transformers/desugar-interpolation-expre...

28 lines
747 B
JavaScript

"use strict";
const NoChange = require("astformer/actions/no-change"); // FIXME
module.exports = {
name: "desugar-interpolation-expressions",
visitors: {
NixAttributePath: (node) => {
if (node.attr.length === 1 && node.attr[0].type === "NixInterpolationExpression") {
// Special case: something like `{ ${foo} = "bar"; }` where the interpolation is expressed without surrounding string literal syntax
return {
... node,
// TODO: Move construction to _nixTypes
attr: [
{ type: "NixStringLiteral", parts: [
{ type: "NixInterpolationLiteral", value: "" },
node.attr[0],
{ type: "NixInterpolationLiteral", value: "" },
] },
]
};
} else {
return NoChange;
}
}
}
};