Modules and view default extension


(Jacob Moen) #1

I am using the Tale Jade Yii renderer with Yii and it works great, except for modules.

I am setting the default view extension to ‘.jade’ and everything works with Yii::Application: if I have two view files like ‘account.php’ and ‘account.jade’, Yii will intelligently use the Jade version.

However, for modules, the behaviour is quite funky. ;D

I am using Dektrium/yii2-user and I have setup the pathmap for the view component.

It works for php views, but when I change the overridden views to jade views, Yii rudely chooses to use the php versions from the user module…

BUT…!

If I create an empty view file in the Dektrium view folder, Yii suddenly chooses to respect my rules :lol:

For example:

I have ‘@common/views/profile/show.php’ and Yii does indeed use that instead of ‘@dektrium/user/views/profile/show.php’

When I change ‘@common/views/profile/show.php’ to ‘@common/views/profile/show.jade’ I would expect Yii to use that, but it doesn’t.

So, I create a completely empty show.jade and drop it in ‘@dektrium/user/views/profile/’ and it works - Yii uses my overridden jade view file. :P

Even if the original ‘show.php’ view file is present.

This must be a bug, right?


(Jacob Moen) #2

It looks like Yii is checking the original view directory to see if a template with the default extension is present.

It should use the pathmap!

I know that I can work around this by dropping empty jade files in my vendor directory (@dektrium/…) but that is not optimal, even if I am not technically changing anything…