我有一個bug已經困擾了我好幾天。我很新的節點和玉模板系統,忍耐一下:我希望通過以下方式添加樣式表:玉模板「每個」功能返回空對象
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});
});
});
佈局。玉(與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'
現在..這個確切的模板可以在另一個應用中傳遞完全相同的變量:我真的很感謝你們在這個棘手問題上提出的任何建議!
謝謝! 馬特·穆勒