Skip to content

Custom paths for Twig files #7459

Closed
Closed
@ste93cry

Description

@ste93cry

Currently all the twig files have to be put inside the Resources/views folder of the app or bundle folder. Some time ago a new option was added to add new paths where the file locator should search for. However, I'm unable to use it because it seems that they are ignored. We can analyze a simple test case where I want to have some templates inside the directory bundle/Resources/templates/mytemplate/views. I add the path to the config, then I render from a controller a template which resides in that folder with the usual string Bundle:MyControllerName:mytemplate.html.twig. This string is then converted to a resource location which starts with the @ and the file locator is called. However when a path starts with that symbol it doesn't call the locate method of the FileLocator class but it calls the locateResource method of the HttpKernel class which knows nothing about the paths and just throws the exception of file not found. Maybe I'm understanding wrong how the paths options should be used: if it's the case, then please help me understand how can I use custom path locations for my templates.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions