0

I am learning Durandal 2 in the hopes of converting my CMS' admin backend into an SPA. I managed to get Durandal to work with the MVC routes and all, but there's one big hiccup I have run into which may be a showstopper here.

I have a plugin architecture, something as follows:

    Main CMS Project
    - Lib 1
    - Lib 2
    - etc...
    - Plugins Folder
       - Plugin 1
       - Plugin 2
       - Plugin 3
       - etc...

I am thinking I can easily grab the routes from MVC via something like System.Web.Routing.RouteTable.Routes. Then I would send that to Durandal via a controller action in the form of JSON and pass it to router.map(). That sounds good in theory. However, there is one very big issue here and that is Durandal seems to expect that every route MUST have a script associated with it (one .js file and one .html file by default).

The obvious issue here is for this to work, I would need to have ALL of the scripts from the different plugins inside my main project, example:

Main CMS Project
- App
   - viewmodels
      - admin
         - pages
            pages.js
         - blog
            blog.js

Something like that I suppose. Where pages and blog may be in a different library or plugin along with various other routes. This is of course impossible. Is there either some way to modify the location of some of the scripts or some way to have ONLY html without the .js files in some cases? With the latter, I could manually load whatever .js files I wanted to in the .cshtml files.

Matt
  • 6,787
  • 11
  • 65
  • 112
  • 1
    Please take a look at http://aurelia.io/. Aurelia is the spiritual successor to Durandal 2. Durandal 2 is in maintenance mode, whereas Aurelia is being actively developed and is built on the latest web standards. – Matthew James Davis Jul 08 '15 at 17:59

1 Answers1

1

little confused as to what you want to know, but durandal is a javascript spa framework, so yes, your plugins would need to be written in javascript. however they don't have to have a html page with them.

You could create a module (js) ( you will have to look on there docs, I wont link as this could potentially change ).

or you can create a widget ( js, html ) that would be used as a plugin, and integrated with the compose function ( very powerful ).

The other alternative would be to create them as just normal AMD packages, much like how durandal is built. So in theory, router in durandal is an AMD component and is used by durandal as a plugin, you could write your own router, and simply switch out theres with your own, essentially creating your own plugin.

Another option would be to create your own durandal plugin, that handles your other plugins in the way that you require and have already set up.

Last but not least, Durandal is good, but if this is a new project, and you like durandal, them ideally you would be using Aurelia instead, by the same company, but much better, like durandal on steroids and with much more control over very complex systems.

davethecoder
  • 3,856
  • 4
  • 35
  • 66