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

Global macros in 2.x #2644

Closed
nbonamy opened this issue Mar 3, 2018 · 1 comment
Closed

Global macros in 2.x #2644

nbonamy opened this issue Mar 3, 2018 · 1 comment

Comments

@nbonamy
Copy link

nbonamy commented Mar 3, 2018

Hello,

I am migrating a code base from Twig 1.x to 2.x.

Macros where loaded globally with a custom extension like this :

public function initRuntime(Twig_Environment $environment) {
	$environment->addGlobal('...', $environment->loadTemplate('...'));
}

Running this in 2.x throws an exception:
Unable to add global "..." as the runtime or the extensions have already been initialized

I cannot find a way to do this in 2.x reading the docs.

Is it still supported? If yes, what is the proper way to do this?

Thanks,
Nicolas

@fabpot
Copy link
Contributor

fabpot commented Mar 11, 2019

Closing as this is not supported anymore at runtime. But they can still be registered in the extension itself.

@fabpot fabpot closed this as completed Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants