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

  • Home
  • SEARCH
  • 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 6322947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:25:38+00:00 2026-05-24T16:25:38+00:00

I’ve had a bug that has been bugging me for days. I’m pretty new

  • 0

I’ve had a bug that has been bugging me for days. I’m pretty new to Node and the Jade templating system so bear with me: I’m looking to add stylesheets in the following way:

App.js (Express):

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});

 });

});

In layout.jade (which is executed with app.jade) I have:

!!! 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 )

Plus more… I keep running into the same error:

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'

Now.. the gotcha is that this exact template works in another application that passes in the exact same variables: I would REALLY appreciate any suggestions you guys have on this thorny issue!

Thanks!
Matt Mueller

  • 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-05-24T16:25:38+00:00Added an answer on May 24, 2026 at 4:25 pm

    So here’s your issue…

    in this line:

    res.render('app.jade', {locals : locals});

    you are passing in locals ==> locals, which is a hash (ok, so I’m a PERL guy, I think JS calls them ‘associative arrays’)

    So now inside your jade template we have the line:

     - var stylesheets = stylesheets || []; 

    inside JADE, you have defined the variable “locals”, but everything else is hidden under that, so the variable “stylesheets” is NOT defined (locals.stylesheets is defined instead). So this line of code sets the variable “stylesheets” to “[]”

    So here’s where I have to speculate. “indexOf” is a method of the Array object. Perhaps arrays constructed inside JADE don’t have this method whereas arrays constructed in node.js DO have this method. Which would explain why you get an error trying to call “stylesheets.indexOf(…)”

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

Sidebar

Related Questions

No related questions found

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.