rcrowe / TwigBridge

Give the power of Twig to Laravel
MIT License
895 stars 166 forks source link

"extends" keyword requires absolute path #159

Open webwisejordan opened 10 years ago

webwisejordan commented 10 years ago

After updating recently to TwigBridge 0.6 from 0.5 alongside an update from Laravel 4.1.x to 4.2.x, templates are no longer rendering when using the "extends" tag inside of a file.

As an example, provided I have a directory at /var/www/laravel_test/app/modules/main/views which contains two files: "home.twig" and "template.twig"

If the home.twig file is like this:

{% extends "template.twig" %} stuff here...

I get an error saying that "Template "template.twig" is not defined () in "/var/www/laravel_test/app/modules/main/views/home.twig"... if I change the home.twig file to this:

{% extends "/var/www/laravel_test/app/modules/main/views/template.twig" %} stuff here...

then it works fine. Either way worked fine in 0.5, so the issue seems to be that the extends tag is now not using a relative path from the child template to reference inherited templates, but rather an absolute path.

barryvdh commented 10 years ago

And just template?

webwisejordan commented 10 years ago

Just template does the same thing as template.twig

webwisejordan commented 10 years ago

As an update, I have found that I can make this work by using a full relative path from public/index.php, so changing the home.twig file to this

{%extends "../app/modules/main/views/template.twig" %} stuff here...

will at least display correctly - but this is really more of a temporary fix for me, I would ultimately like to get this working the way it should be. Has anyone else had this issue?

kaidesu commented 9 years ago

Pretty sure this is because you have not registered a view namespace for your modules directory. Laravel has no idea you have views inside of app/modules/main/views otherwise.

This isn't a bug with TwigBridge.

stefanbauer commented 8 years ago

Here is exactly the same thing the way around. I have to use only the filename (without extension) when i extend from some other template. This is unusual as i find. In regular twig i use {% extends 'some_template.html.twig' %} and not {% extends 'some_template' %}. In that case

a) php storm can not follow that template (only with full filename) b) it should be follow the origin twig conventions.

In this case the twig bridge expects generally *.twig files.. Here is again the problem. PHPStorm can not follow the templates if you use view('template'). If you change in the config the suffix to html.twig (standard) then phpstorm can follow. But doesn't change anything with that extends problem.

barryvdh commented 8 years ago

You can't use the extension, because it uses the laravel Viewfinder to find the template, which doesn't need an extension. You could add the view dir to the Twig fileloader probably