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

Make mixins defined in styleguide accessible globally #406

Open
Wolfr opened this issue Aug 10, 2021 · 2 comments
Open

Make mixins defined in styleguide accessible globally #406

Wolfr opened this issue Aug 10, 2021 · 2 comments

Comments

@Wolfr
Copy link
Contributor

Wolfr commented Aug 10, 2021

Idea for Bedrock.

If you define a mixin anywhere in content/_components/<your-component> it could become available in all templates.

This could be done by Bedrock scanning the contents of all files in _components and taking out any mixins, and then adding all those mixins to the global “namespace”.

The manual way to do right now is define mixins in content/_mixins/all manually. The problem with this is that it makes your code live both in _components and in _mixins.

It would be cleaner if there is a single place for your definition.

@Wolfr
Copy link
Contributor Author

Wolfr commented Nov 16, 2021

Reading this idea a few months later it sounds a bit fragile, but co-location of code would still be nice, and would alllow you to work in Bedrock in a way that's more like in most modern JS frameworks.

@Wolfr
Copy link
Contributor Author

Wolfr commented Nov 29, 2021

Reading this again it sounds like it could make Bedrock slower if we are not careful.

One other implementation strategy might be to put the mixin in a specific format so that it becomes scannable. E.g. all mixins are in a filled called *.mixin.pug

And thus we can join the contents of all of these files and then make those mixins available in the global namespace.

However I don't think we can implement this without requiring a server restart.

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

1 participant