user1492051
user1492051

Reputation: 906

jade and client side javascript

I just started learning Express for nodejs using jade as a rendering engine, i have views and routes

Here are my views

layout.jade

  doctype html
    html
      head
        title= title
        link(rel='stylesheet', href='/stylesheets/style.css')
        link(href='/themes/bootstrap.min.css', rel='stylesheet')
        script(src='/javascripts/mygridwidjet.js', type='text/javascript')
      body
    block content

index.jade

extends layout

    block content
      h1= title
      p Welcome to #{title}
          .content-container-fluid
          .row
              .cols-sample-area
                  #Grid

and here are my routes

index.js

exports.index = function(req, res){
  res.render('index', { title: 'Football Archive' });
};

and i wrote my client side javascript which interacts with the #Grid

now i am really confused about where to put the client side javascript.

ps: i am a total noob, sorry if this question is so stupid.

Upvotes: 3

Views: 2214

Answers (1)

Vinz243
Vinz243

Reputation: 9938

You must put it in the folder public/ (create it if it does not exists)

myapp
 |
 |-node_modules/
 |   |-express/
 |   |-socket.io/
 |
 |-public/
 |   |-javascripts/
 |   |    |-mygridwidjet.js
 |   |-...
 | 
 |-server.js

Here is a more complex example (my app) : https://github.com/CraftYourModCorporation/RedstoneHub

Upvotes: 2

Related Questions