-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
main controller does not use same twig instance #3065
Comments
This is not enough information to do anything with. Please provide detailed issue reports that actually describe what you are trying to do and why it is not working. |
Trying to register |
@oleg-andreyev I'm still not sure what you are trying to do. Does http://octobercms.com/docs/plugin/registration#extending-twig help? |
Instead of creating new instance of |
ping |
What is it exactly that you are trying to do that requires the template_from_string? I understand how you're running into issues with your approach, what I'm looking for is what you are actually wanting to do with that. |
I have form with prototype element, when I click on button it's adding new field. |
I'm afraid I still have no idea what you're talking about. Are you trying to render a Twig template from a string? |
To keep it simple, yes, I need to render template from string. |
@oleg-andreyev does use Twig;
Twig::parse($templateString, $templateVars); not work for some reason? |
I'm trying to do something like @oleg-andreyev. |
@KonstantinObuhov Using the Twig facade by itself won't load any CMS extensions, to fix that just register them again in your plugin instead. See modules/cms/ServiceProvider.php |
@LukeTowers imo application should have single instance of Twig (unless there is really specific case), and it should accessible by all plugins via DI and facade should provide access to it. Case
Because Twig instances isn't shared |
@oleg it already does. The CMS is a specific exception because it is a removable module, you don't have to use the CMS module to have a working October instance. It registers its own twig extensions only when it's actually being used, as opposed to the System module and all plugins loaded by the System module |
I do agree that the behaviour is confusing for new developers, I myself spent a few hours figuring out why CMS extensions weren't working in my custom twig parsing. Perhaps you should submit a PR to include the CMS extensions in the global twig instance by default, although you'd have to keep in mind possible conflicts with the Mail twig instance / extensions |
Main controller does not use same instance of Twig which does not allow to register custom extensions, in make case it's
\Twig_Extension_StringLoader
The text was updated successfully, but these errors were encountered: