본문으로 건너뛰기

Globs

Etymology

The glob command, short for global, originates in the earliest versions of Bell Labs' Unix... to expand wildcard characters in unquoted arguments ...

https://en.wikipedia.org/wiki/Glob_(programming)

Globs are a powerful language feature to make global changes in one line.

iphone 10iphone 11 miniiphone 11 proiphone 12 mini

Globs apply backwards and forwards

In the following example, the instructions are as follows:

  1. Create a shape a.
  2. Apply a glob rule. This immediately applies to existing shapes, i.e., a.
  3. Create a shape b. Existing glob rules are re-evaluated, and applied if they meet the criteria. This does, so it applies to b.
  4. Same with c.
aybc

Globs are case insensitive

diddy kongDonkey Kong

Globs can appear multiple times

teacherthrillerthrifter

Glob connections

You can use globs to create connections.

Spiderman 1Spiderman 2Spiderman 3 👉👉👉👉👉👉
정보

Notice how self-connections were omitted. While not entirely consistent with what you may expect from globs, we feel it is more pragmatic for this to be the behavior.

You can also use globs to target modifying existing connections.

lady 1lady 2barbie hi barbiehi barbie

Scoped globs

Notice that in the below example, globs only apply to the scope they are specified in.

foodspizzashumanscheesesausagepineapplejohnjames eatseats

Recursive globs

** means target recursively.

abc
zone-Aload balancermachine Amachine Bsubmachine Asubmachine B
정보

Notice how machine B was not captured. Similar to the exception with * -> * omitting self-connections, recursive globs in connections also make an exception for practical diagramming: it only applies to non-container (AKA leaf) shapes.

Filters

Use & to filter what globs target. You may use any reserved keyword to filter on.

bravo teamcharlie teamcommand centerhq

Property filters

Aside from reserved keywords, there are special property filters for more specific targeting.

  • connected: true|false
  • leaf: true|false
containercab

Filters on array values

If the filtered attribute has an array value, the filter will match if it matches any element of the array.

the-little-cannondinocatapult

Globs as filter values

Globs can also appear in the value of a filter. * by itself as a value for a filter means the key must be specified.

xy

Connection endpoint filters

Connections can be filtered by properties on their source and destination shapes.

abc

Endpoint filters also work with IDs, e.g. &src: b.

정보

Endpoint IDs are absolute. For example, a.c instead of just c, even if the glob is declared within a.

Inverse filters

Use !& to inverse-filter what globs target.

bravo teamcharlie teamcommand centerhq

Nested globs

You can nest globs, combining the features above.

conversation 1conversation 2alicebobalicebob hihihello againhello?hello

Global globs

Triple globs apply globally to the whole diagram. The difference between a double glob and a triple glob is that a triple glob will apply to nested layers (see the section on composition for more on layers), as well as persist across imports.

Imports

If you import a file, the globs declared inside it are usually not carried over. Triple globs are the exception -- since they are global, importing a file with triple glob will carry that glob as well.

Changing defaults

One common use case of globs is to change the default styling of a theme.

xy