visionmedia/express — Issue #900: Client Javascript and stylesheet injection issues
Author: robhicks
Created: 2011-11-23 04:05:42+00:00
State: open

I am trying to write my first Express app.

I am using the vanilla Express install with Jade and Stylus.

I am switching layouts for part of the app. I'm using the following route to switch layouts:

`exports.login = function(req, res) {
res.render('login', {
layout: 'auth_layout.jade',
title : 'Login'
});
};
`
And in this layout, I have a number of css and javascript links/scripts:

`
link(rel='stylesheet', href='/stylesheets/reset.css')
link(rel='stylesheet', href='/stylesheets/text.css')
link(rel='stylesheet', href='/stylesheets/960.css')
link(rel='stylesheet', href='/stylesheets/validationEngine.jquery.css')
link(rel='stylesheet', href='/stylesheets/main.css')
link(rel='stylesheet', href='/stylesheets/login.css')
script(type='text/javascript',src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js')
script(type='text/javascript',src='/javascripts/jquery.validationEngine.js')
script(type='text/javascript',src='/javascripts/login.js')
`

Note that one of the css files linked in is login.css. And, the last javascript file is login.js.

When these files are rendered into the browser, their contents are injected with the contents of the dom for the app:

`

Login

Home
Pricing
Docs
Support
Jobs
Blog
Signup
Login

Username:

Password:

Remember Me?
Forgot your password?
Recover it here.

Or sign in with:

Help spread the word about

Support |
Terms & Conditions |
Privacy Policy
© 2011, ABC, Inc.

`

It appears that Express or Stylus is injecting the dom into files with the same name as the Jade route file. If I name/rename the files and links something else, this problem doesn't occur.