terrastruct / d2

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

feature request: if #1539

Open bo-ku-ra opened 1 year ago

bo-ku-ra commented 1 year ago
vars: {
distribution: 1; #true
}

a:"you"{

e-mail:foo@foobar.com
_phone-no:"mobile: 1111-1111"
}

b:"me"{
e-mail:bar@foobar.com
_phone-no:"mobile: 2222-2222"
}

if ( ${distribution} == 1) {
 *._** : null
} else {
 *._** : { style.font-color: red;}
}
soma-m commented 1 year ago

I've missed the if statement as well.

To simplify the syntax we could also remove the brackets after if

E.g.

if ${variable} == 0

instead of

if ( ${variable} == 0 )

alixander commented 1 year ago

declarative languages don't have branching, and I don't think D2 should.

i don't think the example is motivating enough.

bo-ku-ra commented 1 year ago

i can see the policy.