terrastruct / d2

D2 is a modern diagram scripting language that turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
16.8k stars 421 forks source link

Variable substitution inside markdown text #1667

Open albertored11 opened 1 year ago

albertored11 commented 1 year ago

It would be great to be able to reference variables inside markdown text blocks and have D2 automatically substitute them.

For example, compiling the following D2 code

vars: {
  myvar: myvalue
}

mybox: myvar has value ${myvar}

mybox1: |md
  myvar has value ${myvar}
|

produces this output:

diagram

but with the variable substitution feature, we would get this one instead:

diagram

ppalka-lingaro commented 1 year ago

When I try to find a solution playgraund resolved myvar to myvalue :) is it a bug ?

vars: {
  myvar: myvalue
}

mybox1: |md
  myvar has value ${myvar}
|

mybox2: myvar has value ${myvar}

after compile

vars: {
  myvar: myvalue
}

mybox1: |md
  myvar has value ${myvar}
|

mybox2: myvar has value myvalue
mrsaiz commented 1 year ago

For me is not working, same result locally than in the d2-studio-playground

image