WebFund 2013F Lecture 5

From Soma-notes
Jump to navigation Jump to search

Audio from the lecture given on September 23, 2013 is here.

Readings

  • Chapter 4 in Learning Node (Modules)

Topics

  • node modules
  • function arguments array
  • return values

Notes

September 23

var express = require('express')
  , routes = require('./routes');
  • in the case of node, var express makes a local variable
    • this means it is global (but private to) a file
    • ./routes - a directory in the directory you are in
    • express is somewhere else
      • express is in the node module directory
      • "look for the code in the express directories in one of the node modules"
  • npm install populates the node modules directory
  • exports object is a special object
exports.add = function(req, res){
    res.render('add', { title: 'Person added',
			name: req.body.name,
			country: req.body.country,
			date: req.body.birthday,
			email: req.body.email});
  • come from text fields on page input from user
  • res.render
    • rendering in graphics -rendering a ball, wire frame, textures, lighting etc.
    • this is what creates the page
    • default renderer is jade
      • provides a template for entire page that is then filled in with parameters
h1 Info Added
p Name: #{name}
p Country: #{country}
p Date: #{date}
p Email: #{email}
  • describes what your page will look like
  • !!! is used in jade
    • stuff needed for standard syntax
    • doctype html
  • jade-lang.com/reference
  • html, jade, css, javascript
  • html
    • markup language with tags using angle brackets <> </>
  • indentation in jade is very important
    • kind of like python
    • language for generating html pages
  • div are divisions
    • essentially specifying a block
  • any time you call a function in javascript there is a thing called arguments
    • it is bound to an area with all the arguments
    • function takes a variable amount of arguments
  • push
    • in java script an array is already a stack
    • can push an element on the top
    • works for the first element in the array
  • pop
    • works for the last element of the array
  • arrays are variably sized objects
    • can be accessed in different throughout
    • ordered
    • similar to object
    • loosely typed