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

Add "Globals" Twig Extension Support #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sghoweri
Copy link

@sghoweri sghoweri commented Nov 4, 2017

https://twig.symfony.com/doc/2.x/advanced.html#id1

This update will continue to unlock even more interesting options for us in cross-platform Design System interoperability -- especially with things like shared Design Tokens, schema data, default inherited properties (cough Drupal Attributes cough), and more. Addresses #46

Example of this being used out in the wild (ex. sharing the default responsive img srcset breakpoint sizes): https://github.com/bolt-design-system/bolt/blob/develop/packages/bolt-twig-extensions/globals/bolt-image-sizes.global.php

CC @aleksip @bradfrost

Side question / point of interest:
Note that this extension, unlike the other Twig extension integrations in Pattern Lab, doesn't require us to use some $function = new Twig_SimpleFunction('NAME', function ($params) { ... }); wrapper -- potentially allowing opening the door for other Twig functions, filters, tags, tests and operators to get added in the same manner (ie. the same extension getting used in another environment supporting Twig could perhaps just get dropped in verbatim)

…t for global variablesf, allowing for cross-platform interoperability. Addresses #46
@sghoweri sghoweri requested a review from EvanLovely November 4, 2017 18:36
@sghoweri sghoweri requested a review from aleksip November 29, 2017 13:23
@EvanLovely
Copy link
Member

Hmm... now that I'm looking at this closer, I'm not too big of a fan of making a new Twig Extension for each global file. I'd prefer if we just used $self::$instance->addGlobal().

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

Successfully merging this pull request may close these issues.

3 participants