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();
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());
});
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:
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.
source
share