Using partial expressions with an expression in node.js

I am trying to do partial use with node.js. Here is my code.

app.js:

  var express = require('express')
  , routes = require('./routes');

var app = module.exports = express.createServer();

// Configuration

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

app.configure('development', function(){
  app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.configure('production', function(){
  app.use(express.errorHandler());
});

// Routes

app.get('/', routes.index);

var products = require('./products.js');

app.get('/products', function(req, res) {
    res.render('products/index', {locals: {
               products: products.all
               }
               });
});

app.listen(3000);

When I switch to localhost: 3000 / products, it should display index.jade, which is in the products folder, which is in the views.Above folder. I am installing the views directory withapp.set('views', __dirname + '/views');

index.jade:

h1 Products:
#products!= partial('partials/product', {collection: products})

This should make the partial equivalent (partials / product.jade) because jade is my view mechanism.

I get an error saying "partial not defined"

Any help would be great. thank

UPDATE:

This solved my partial error, thanks. I reinstalled 2.5.9.

+3
source share
1 answer

, Express JS ​​- 3.0 alpha:

$ npm ls
...
└─┬ express@3.0.0alpha1
...

, 2.x 3.x. , res.partial() partial() ( ) - " :"

"" Express 3.x, -. .

, Jade, .

, , 2.x.

$ npm install express@2.x

package.json:

{
    ...
    "dependencies": {
        ...
        "express": "2.x"
    }
}
+8
source

All Articles