Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

Add "Globals" Twig Extension Support#47

Open
sghoweri wants to merge 1 commit into
masterfrom
feature/add-twig-globals
Open

Add "Globals" Twig Extension Support#47
sghoweri wants to merge 1 commit into
masterfrom
feature/add-twig-globals

Conversation

@sghoweri
Copy link
Copy Markdown

@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
Copy Markdown
Contributor

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants