Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

ModulePath View Resolution not making sense #766

Closed
phillip-haydon opened this issue Sep 27, 2012 · 4 comments
Closed

ModulePath View Resolution not making sense #766

phillip-haydon opened this issue Sep 27, 2012 · 4 comments
Milestone

Comments

@phillip-haydon
Copy link
Member

Given a module:

public class HomeModule : NancyModule
{
    public HomeModule()
    {
        Get["/"] = _ =>
        {
            return View["index"];
        };
    }
}

The route is defined as:

http://localhost/

The View is looked for in:

Views/Home/index


When using a ModulePath

    public class HomeModule : NancyModule  
    {
        public HomeModule() : base("admin")
        {
            Get["/"] = _ =>
            {
                return View["index"];
            };
        }
    }

The route is located by:

http://localhost/admin/

The View should be located first in:

Views/Admin/Home/index

Then

Views/Home/index

What is happening is it's trying to find the views in:

/Admin/index


What I think should happen:

When a ModulePath is defined as:

base("admin")

The View resolution should be found in the Views folder as per normal modules, the difference being that the flow is:

Views / *MODULE PATH* / *MODULE NAME* / *VIEW NAME*
Views / *MODULE NAME* / *VIEW NAME*
Views / *VIEW NAME*

Is a ModulePath is defined with a forward slash prefix:

base("/admin")

Then the View resolution should be:

/ *MODULE PATH* / *MODULE NAME* / *VIEW NAME*
/ *MODULE PATH* / *VIEW NAME*
@phillip-haydon
Copy link
Member Author

Also to add to the fact this is a bug. If you have two Modules both defined as HomeModule, one in a ModulePath and one without.

When using the ModulePath, it will always look in the Views folder first before looking for the Module Path in the root directory, so it's not possible to have two views named the same, it will always load the incorrect view for the ModulePath.

@phillip-haydon
Copy link
Member Author

I'm just implementing this into Nancy now.

I want to get the order of these correct so here's the list I think should be from first to last:

views / *modulepath* / *modulename* / *viewname*
*modulepath* / *modulename* / *viewname*

views / *modulepath* / *viewname*
*modulepath* / *viewname*

views / *modulename* / *viewname*
*modulename* / *viewname*

views / *viewname*
*viewname*


Currently it's

views / *modulepath* / *viewname*
views / *modulename* / *viewname*

*modulepath* / *viewname*
*modulename* / *viewname*

views / *viewname*
*viewname*

Thoughts?

@thecodejunkie
Copy link
Member

@phillip-haydon yeah I think these makes sense to have in the core

@thecodejunkie
Copy link
Member

Fixed in #771

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

No branches or pull requests

2 participants