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

Namespaced Twig paths not working #654

Closed
SvetlinStaev opened this issue Dec 16, 2015 · 10 comments
Closed

Namespaced Twig paths not working #654

SvetlinStaev opened this issue Dec 16, 2015 · 10 comments
Labels

Comments

@SvetlinStaev
Copy link

Firstly, let me say that this plugin is the very best in terms of Symfony 2 integration and I really enjoy it working with it. Keep up the good work!

There is a small issue with the Twig templates when they are referenced as with their namespaced paths:

in config.yml

twig:
    paths:
        "%kernel.root_dir%/../src/vendor/bundle/Resources/views": core

in the controllers:

return $this->render('@core/path/template.html.twig');

or in the templates:

{% include '@core/path/template.html.twig' %}

This plugin doesn't recognise the shortcut. Is it a bug or it is not technically possible to parse the configuration to reference the namespace paths?

@mpdude
Copy link

mpdude commented Apr 11, 2016

Here's the Symfony documentation for this syntax: http://symfony.com/doc/current/cookbook/templating/namespaced_paths.html

@lstrojny
Copy link

Existing bundles are added automatically. E.g. for the SensioDistributionBundle one can reference templates using @SensioDistribution/path/to/template.html.twig.

@Haehnchen Would fr.adrienbrault.idea.symfony2plugin.TwigHelper be the correct place to start implementing this?

@Haehnchen
Copy link
Owner

yes, in detail fr.adrienbrault.idea.symfony2plugin.TwigHelper#getTemplateMapProxy provides path mapping

@lstrojny
Copy link

Maybe this solves the issue for somebody else: we were able to work around the issue by auto generating a ide-twig.json file for our bundles.

@Haehnchen
Copy link
Owner

done

@lstrojny
Copy link

From testing the newest release and reading the source it looks like this implements the part where one configures twig namespace aliases, not the Symfony core functionality where third party bundle namespaces are automatically configured, correct? If so, any plans to implement the latter and should I open another issue for it?

@Haehnchen
Copy link
Owner

@lstrojny what is not working on your side? bundles namespaces are in for years. did i forget a use case? :)

@lstrojny
Copy link

@Haehnchen let's say I have a bundle called FooBundle and I use Symfony. The TwigBridge will automatically register FooBundle/Resources/views to be available as @Foo, so I can simply use this in my template:

{% include '@Foo/my/view.html.twig' %}

After updating the Symfony2 plugin to the latest version, for me this doesn’t work. Do I overlook something?

@Haehnchen
Copy link
Owner

@lstrojny its implemented. check Lanugaes & Frameworks > Symfony > Twig for namespace. if you need support or feedback pls to #784

Haehnchen added a commit that referenced this issue Oct 9, 2016
@vbsessa
Copy link

vbsessa commented May 25, 2018

Is this issue fixed? I'm still having OPs same problem. Any namespaced path defined in config/packages/twig.yaml are not recognized for autocompletion. As a workaround I have to manually define a namespace and its path in Phpstorm twig config section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants