Create auto import functionality for TWIG macros

Created on 17 February 2023, over 1 year ago
Updated 24 March 2023, over 1 year ago

Problem/Motivation

In TWIG 1 macros had a global scope within your project. I believe it was removed due to security concerns. However there should be a way to call the function since its essentially just a php function.

https://git.drupalcode.org/project/bootstrap_ui_kit/-/blob/1.x/src/TwigE...

I started the functionality but it failed to load when i called it.

I've been calling the function with;

{{ macros_color('swatch', { 'primary' }) }}

The idea being you can call the macro without explicitly importing it into our section, which means less customization.

For example;

color.html.twig

Should be able to access macros inside of;

color.macros.twig

Without having to use the direct import statement via TWIG inside of color.html.twig;

{% import '@bootstrap_ui_kit/ui-kit/' ~ section.id ~ '/' ~ section.id ~ '.macros.twig' as macros %}

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇨🇦Canada AaronChristian Kelowna, BC

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024