У меня была ошибка, которая давала мне много дней. Я довольно новичок в Node и системе шаблонов Jade, так что терпите меня: я хочу добавить таблицы стилей следующим образом:
App.js (Экспресс):
app.get('/', loadUser, function(req, res) {
var User = req.user;
// console.log(User.groups[2]);
// var groups = User.groups.split(',');
// OK DUh. This only gets called when the client has the script Socket.IO
// and client runs socket.connect()
getMessages(User, function(messages) {
var locals = {
scripts: [
'https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js',
'index.js'
],
stylesheets: [
'index.css'
],
user : User,
messages: messages
};
console.log('ok');
res.render('app.jade', {locals : locals});
});
});
В layout.jade (который выполняется с app.jade) у меня есть:
!!! 5
html
head
title UI
link(rel='stylesheet', href = 'stylesheets/reset.css')
link(rel='stylesheet', href = 'stylesheets/layout.css')
- var stylesheets = stylesheets || [];
#{stylesheets}
- each stylesheet in stylesheets
- if(stylesheet.indexOf('http') >= 0)
link(rel='stylesheet', href = stylesheet)
- else
link(rel='stylesheet', href = "stylesheets/"+stylesheet )
Плюс еще ... Я продолжаю сталкиваться с той же ошибкой:
9. ' - if(stylesheet.indexOf(\'http') >= 0)'
Object function () {
var o = {}, i, l = this.length, r = [];
for(i=0; i
for(i in o) r.push(o[i]);
return r;
} has no method 'indexOf'
Теперь ... уловка в том, что этот точный шаблон работает в другом приложении, которое передает те же самые переменные: я ДЕЙСТВИТЕЛЬНО буду признателен за любые ваши предложения по этому сложному вопросу!
Спасибо!
Мэтт Мюллер