I hope you are healthy.
I suddenly fail to display external javascript in jade templates! To understand this, I divided it into a minimum:
Node 0.6.11, Express 2.5.8, Jade 0.20.3
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('/', function(req, res){ res.render('index', { title: 'Express' }); }); app.listen(3000);
layout.jade
!!! html head title= title link(rel='stylesheet', href='/stylesheets/style.css') script(type='text/javascript', src='/javascripts/script.js') body!= body
script.js
alert('hello!');
It seems to me that when I start the server and load http: // localhost: 3000 / , I should immediately receive "hello!". message, but it just launches directly on a regular page. What else if I manually type
script alert('hello!')
in layout.jade template I get the message as it should. It just does not load a static script. And I definitely checked that "script.js" is in '/ public / javascripts /', as it should be. Any advice would be greatly appreciated.
Thanks in advance
source share