Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7823835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:23:26+00:00 2026-06-02T08:23:26+00:00

I am learning to use Express. I want to do: app.configure(function(){ app.set(‘views’, __dirname +

  • 0

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:

  • use ‘layout:false’ for Jade.
  • pretty-print the HTML in Jade.
  • turn on the logger, with the ‘dev’ format

There are two problems:

  1. /* 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?

  2. /* 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:23:27+00:00Added an answer on June 2, 2026 at 8:23 am

    I checked in the express source code and the app.set function simply assigns over top of any previous value it had. To get the behavior you’re looking for you’ll have to merge the view options object in subsequent calls. This means you’ll probably have to jump through a couple of hoops. The connect package has a merge function that will work for this but to get it you’ll have to include it in your package.json:

    "dependencies": {
      "express": "2.5.5"
    , "jade": ">= 0.0.1"
    , "connect": "1.X"
    }
    

    You’ll need to get the utils object from connect:

    var utils = require('connect').utils;
    

    app.set(option) with no value returns the current setting for the option so the second time you set view option you could do it this way:

    app.set('view options', utils.merge(app.set('view options'), { pretty: true }));
    

    As for the problem you’re having with the logger, remember that app.use is adding pieces of middleware to a stack. As a request is being processed it calls each piece of middleware in the order they are originally configured and sometimes if a piece of middleware is able to fulfill its duty it will not pass control to subsequent middleware in the stack.

    This is the case with the router middleware when it fulfills a request for the '/' url where logger is not subsequently run. The reason the request for favicon.ico shows up in the log stream is that none of the middleware was able to fulfill it (the static middleware would if you had a public/favicon.ico file) and processing falls through to the logger middleware.

    To make your example work you’ll need to define the logger middleware earlier in your stack, before the router middleware.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning to use the Rx extensions for a Silverlight 4 app I
I am currently learning to use the Propel ORM, and I want to reuse
I am learning log4net and currently testing out how to use App.Config for XMLConfiguration.
I'm learning to use ImageMagick, but I'm having trouble when I try to generate
I am learning to use LabVIEW as part of my honours project, and was
I have been learning to use Emacs for a little while now. So far
I am learning to use polymorphism in C#, but cannot figure out this one.
I am learning to use the Dvorak keyboad layout, but I am not good
I'm learning to use vlad the deployer and I've got a question. Since I'm
I'm learning to use raw sockets, and im trying to prase out the tcp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.