Express MVC with sub-apps and shared templates/views

35 views
Skip to first unread message

Tom Kiddle

unread,
Mar 5, 2015, 11:55:08 PM3/5/15
to expre...@googlegroups.com

Node MVC

Ok so I’m currently building a Node/Express MVC boilerplate for all future projects. The requirements dictate that sub apps must be supported to help organise code, and to create a separation of concerns amongst different areas of the site e.g. user account section and the non-authenticated area of the site.

My progress can be seen here: https://github.com/tkiddle/expressPlate/tree/tkiddle

So far I’ve created a way of supporting sub apps and organising controllers per sub app.

The current structure looks a bit like this:

ROOT
 | - server.js
 | - package.json
 | - views
    | - index.jade
 | - apps
    | - admin
        | - models
        | - controllers
        | - views
            | - assets
            | - templates (jade templates)
    | - blog 
        | - models
        | - controllers
        | - views
            | - assets
            | - templates (jade templates)
    | - events 
        | - models
        | - controllers
        | - views
            | - assets
            | - templates (jade templates)

I’d like to support both isolated views/jade templates (views specific to a specific sub app) and shared view/templates (views that can be shared across multiple sub-apps). My thinking is that when rendering a view within a sub app if the template is not found it looks for it in the ROOT->views directory for it.

This will also allow me to have one common index.jade template (in the ROOT->views directory)and for each sub-app’s template/jade files the ability extend that.

I’m at a slight loss with this. Can anyone provide a solution for doing this?

Reply all
Reply to author
Forward
0 new messages