terrastruct / d2

D2 is a modern diagram scripting language that turns text to diagrams.

Home Page:https://d2lang.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variable Scoping not honored on imports

Tyler-Hartwig-Pariveda opened this issue · comments

Hi, I ran into an issue with importing diagrams and variable scoping:

template.d2

env: {
  label: ${env} Environment
  vm: {
    label: My Virtual machine!
  } 
}

environments.d2

dev: {
  vars: {
    env: Dev
  }
  ...@template.d2
}

qa: {
  vars: {
    env: Qa
  }
  ...@template.d2
}

I'd expect this to render with "Qa" and "Dev" in each respective environment, instead "Dev" is used on both diagrams!

@Tyler-Hartwig-Pariveda is this the full script? Do you mean to import template.d2 in the qa scope too?

@Tyler-Hartwig-Pariveda is this the full script? Do you mean to import template.d2 in the qa scope too?

That's correct, sorry, i missed that, I'll go update the original post!

ty for reporting this