Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[variables substitution] Allow substitution inside map keys #2181

Open
Melandel opened this issue Oct 30, 2024 · 1 comment
Open

[variables substitution] Allow substitution inside map keys #2181

Melandel opened this issue Oct 30, 2024 · 1 comment

Comments

@Melandel
Copy link

Melandel commented Oct 30, 2024

Hello 🌱

At the time of writing this issue

Given this d2 description text:

vars: {
  x: "Data"
}

cls: "SomeClass" {
  shape: class
}
cls."Process(Input input)": ${x}Output
cls."Process(${x}Input input)": ${x}Output

This link shows that variable substitution inside a key of the map cls is not effective:
image

Feature Request

I would like the same source code to generate this image instead (substituing the variable x containing the value Data:
image

Would this be a fair request to make?

@cyborg-ts cyborg-ts added this to D2 Oct 30, 2024
@alixander
Copy link
Collaborator

I think is specific to class shapes, because all other keys can have label affect their final render text.

If we allow substitutions in map keys, it becomes too confusing to reference (e.g. point a connection to it).

I'm not sure what to do here other than introduce a new keyword specific to class shape, which is last resort. Will put this on backburner until I can think of something better or someone else runs into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants