title: Node JS + Express : Render subviews in a main view
body: <p>I've got a page which is "Google Card" designed. I want to render some views on the cards of this main page.</p>
  
  <p>The Cards interface looks like this:
  <img src="https://i.stack.imgur.com/dYK8F.jpg" alt="enter image description here"></p>
  
  <p>Because there can be many cards, I organized my project in modules.</p>
  
  <p>(BTW, if you know a framework thats fits more my project than Express does, can you tell it to me? :) )</p>
  
  <p>I'm using Node.js with the Express Framework. My directory structures is this:</p>
  
  <pre><code>|-app
  |--modules
  |---weather
  |---index.js
  |----views
  |-----weather.jade
  |--views
  |--config.js
  |--server.js
  |-public
  |--assets
  |---img
  |---css
  |---...
  </code></pre>
  
  <p>Here is some of my current code:</p>
  
  <p>server.js:</p>
  
  <pre><code>var express = require('express');
  
  var app = express();
  app.use("/public", express.static(__dirname + '/../public'));
  app.set('view engine', 'jade');
  
  Board = {};
  
  Board.modules = {};
  Board.modules.weather = require('./modules/weather');
  
  app.use(Board.modules.sticks);
  
  app.get('/', function(req,res){
      tpl = {};
      tpl.modules = Board.modules;
      console.log(tpl);
      res.render(__dirname + '/views/board.jade', tpl);
  });
  
  app.listen(8080);
  </code></pre>
  
  <p>board.jade (the main page)</p>
  
  <pre><code>doctype html
  html(lang="fr")
    head
      meta(charset="utf-8")
      title Board
      block stylesheets
        link(rel="stylesheet", href="/public/assets/css/reset.css")
        link(rel="stylesheet", href="/public/assets/css/board.css")
    body
      // Background
      div.bg
  
      // Header
      header.topinfo
        span.left.ip
          | 192.168.31.11
        span.center.logo
          span.logo
            span.logo-baseline
        span.right.time
          | 13:37
  
        // Modules
        ul
          each val in modules
            li= val
  
       block scripts
          script(src="/public/assets/bower_components/jquery/dist/jquery.min.js")
          script(src="/public/assets/lib/jquery-taphold/taphold.js")
          script(src="/public/assets/lib/background-check/background-check.min.js")
          script(src="/public/assets/bower_components/masonry/dist/masonry.pkgd.min.js")
          script(src="/public/assets/js/app.js")
  </code></pre>
  
  <p>And the modules/weather/index.js</p>
  
  <pre><code>var express = require('express');
  
  var app = module.exports = express();
  
  app.get('/', function(req,res){
      res.render(__dirname + '/views/sticks.jade');
  });
  </code></pre>
  
  <p>I think the purpose would be like getting the result of the app.get('/') of modules/weather/index.js, but without calling the route, to after insert the result of the rendering into the main view, but I don't know how to do that keeping the modularity of my code...</p>