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

distinguish that imports are not includes #156

Open
alixander opened this issue Jun 13, 2023 · 7 comments
Open

distinguish that imports are not includes #156

alixander opened this issue Jun 13, 2023 · 7 comments

Comments

@alixander
Copy link
Contributor

Screen Shot 2023-06-13 at 10 18 35 AM
@alixander
Copy link
Contributor Author

but maybe we should add an @includes

@alixander
Copy link
Contributor Author

this works:

z
layers: {
  y: {
    _.z.style.opacity: 0.1
  }
}

but if you split out y into its own file, it wouldn't. this could be a use case for includes

@nhooyr
Copy link
Contributor

nhooyr commented Jun 13, 2023

Yea perhaps it should and this should be considered a bug.

@alixander
Copy link
Contributor Author

@nhooyr i don't think so. they're different things.

y.d2

a -> b: hi
(a -> b)[0].style.opacity: 0.1

x.d2

a -> b: hello

...@import y
// vs
/// @includes y

@nhooyr
Copy link
Contributor

nhooyr commented Jun 15, 2023

I don't follow. Why couldn't we just make imports have the same behaviour the same as includes? Why have another way to add a file? The idea after all is you can move any code anywhere into a new file and it'll just work.

@alixander
Copy link
Contributor Author

@nhooyr In my example, if you "import y", it imports an opacity 0.1 connection.
if you "includes y", it imports a connection but makes the existing connection 0.1 opacity.

So they're two different things. And I can see both being useful.

@alixander
Copy link
Contributor Author

maybe @includes can also take in non-d2 files!

e.g. someone wants to embed a code snippet or markdown that's in its own file.

although we don't have syntax to specify language tag and value separately. maybe we should

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

No branches or pull requests

2 participants