I am learning to use Express. I want to do:
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.set('view options', { layout: false }); /* asterisk */
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router); /* dagger */
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
app.use(express.logger('dev'));
app.set('view options', { pretty: true }); /* asterisk */
});
The additions I made were:
There are two problems:
/* asterisk */ when I set 'pretty: true' I am overriding my previous options, rather than adding to them. I.e., my program breaks unless I add { pretty: true, layout: false } which feels redundant and can't be correct. How can I correct it so that I am only "modifying" the view options, rather than "defining" them?
/* dagger */ The logger does not acknowledge my requests, except for /favicon.ico. I find if I remove the app.use(app.router); line, then I'll see both / and /favicon.ico. What is going on here?
As of Express 3.x the use of app.set('view options') is no longer the correct way.
https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x
These options are now set in your app.js using app.locals as in
app.locals.pretty = true;
or to set custom delimiters for ejs
app.locals.open = '}}';
app.locals.close = '{{';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With