piernik piernik - 1 year ago 187
Twig Question

Relative paths in twig or absolute in PhpStorm

I'm new to

. I'm using it in PhpStorm and have problem with paths.

Here is my folder structure:

- template /folder/
- main.twig
- common /folder/
- bootstrap.twig
- nav.twig

I have code:

{% extends "common/bootstrap.twig" %}

When I Ctrl + Click on link PhpStorm opens correct file.

But in
I have to write:

{% include "common/nav.twig" %}

and then Ctrl + Click is not working.
I cannot use relative paths like
- twig throws error.

How can I make twig to use relative paths so go to source would work in PhpStorm?

Answer Source

Mark your template root folder (template in your case) as Resource Root (either via right click in Project View or via Settings/Preferences | Directories).


Files under a folder marked as Resource Root can be referenced relative to this folder.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download