title: What does "res.render" do, and what does the html file look like?
body: <blockquote>
    <p>What does <code>res.render</code> do, and what does the html file look like? </p>
  </blockquote>
  
  <p>My end goal is to load arbitrary comma-separated-values from a text file into an html file (for example). I was only able to deduce that a view was the html file, and callback gives that html file back.</p>
  
  <p>Here is the documentation: <a href="http://expressjs.com/api.html#res.render">http://expressjs.com/api.html#res.render</a>.</p>
  
  <p>Now, given context from some example code I found, there is something about using <code>ejs</code> (embedded javascript) with <code>&lt;%</code> and <code>%&gt;</code>. </p>
  
  <p>But if I may add, am I just incompetent or is the documentation really truly vague and assumes the reader knows everything? How could I have gone about figuring this out on my own? Is there any official documentation so I can gain a full understanding of usage, advantages and pitfalls?<br></p>
  
  <hr>
  
  <p><strong>Edit 1</strong> </p>
  
  <p>I just want to add that I'm having a heck of a time learning <code>node.js</code>. 
  Is it me or is the general documentation really vague? Aside from lousy explanations like above, there are no type specifications for parameters or return values.</p>
  
  <hr>
  
  <p><strong>Edit 2</strong></p>
  
  <p>Let me ask you some more specific questions above the code.</p>
  
  <p>The actual <code>orders.ejs</code> file is in <code>views/orders.ejs</code>. How does this code refer to it?</p>
  
  <p>HTML excerpt:</p>
  
  <pre><code>&lt;tbody&gt;
    &lt;% for(var i=0; i&lt;orders.length; i++) {%&gt;
       &lt;tr&gt;
         &lt;td&gt;&lt;%= orders[i].id %&gt;&lt;/td&gt;
         &lt;td&gt;&lt;%= orders[i].amount %&gt;&lt;/td&gt;
         &lt;td&gt;&lt;%= orders[i].time %&gt;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;% } %&gt;
  </code></pre>
  
  <p>And the js. Please see /orders:</p>
  
  <pre><code>  // Define routes for simple SSJS web app. 
  // Writes Coinbase orders to database.
  var async   = require('async')
    , express = require('express')
    , fs      = require('fs')
    , http    = require('http')
    , https   = require('https')
    , db      = require('./models');
  
  var app = express();
  app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.set('port', process.env.PORT || 8080);
  
  // Render homepage (note trailing slash): example.com/
  app.get('/', function(request, response) {
    var data = fs.readFileSync('index.html').toString();
    response.send(data);
  });
  
  // Render example.com/orders
  app.get('/orders', function(request, response) {
    global.db.Order.findAll().success(function(orders) {
      var orders_json = [];
      orders.forEach(function(order) {
        orders_json.push({id: order.coinbase_id, amount: order.amount, time: order.time});
      });
      // Uses views/orders.ejs
      response.render("orders", {orders: orders_json});
    }).error(function(err) {
      console.log(err);
      response.send("error retrieving orders");
    });
  });
  
  // Hit this URL while on example.com/orders to refresh
  app.get('/refresh_orders', function(request, response) {
    https.get("https://coinbase.com/api/v1/orders?api_key=" + process.env.COINBASE_API_KEY, function(res) {
      var body = '';
      res.on('data', function(chunk) {body += chunk;});
      res.on('end', function() {
        try {
          var orders_json = JSON.parse(body);
          if (orders_json.error) {
            response.send(orders_json.error);
            return;
          }
          // add each order asynchronously
          async.forEach(orders_json.orders, addOrder, function(err) {
            if (err) {
              console.log(err);
              response.send("error adding orders");
            } else {
              // orders added successfully
              response.redirect("/orders");
            }
          });
        } catch (error) {
          console.log(error);
          response.send("error parsing json");
        }
      });
  
      res.on('error', function(e) {
        console.log(e);
        response.send("error syncing orders");
      });
    });
  
  });
  
  // sync the database and start the server
  db.sequelize.sync().complete(function(err) {
    if (err) {
      throw err;
    } else {
      http.createServer(app).listen(app.get('port'), function() {
        console.log("Listening on " + app.get('port'));
      });
    }
  });
  
  // add order to the database if it doesn't already exist
  var addOrder = function(order_obj, callback) {
    var order = order_obj.order; // order json from coinbase
    if (order.status != "completed") {
      // only add completed orders
      callback();
    } else {
      var Order = global.db.Order;
      // find if order has already been added to our database
      Order.find({where: {coinbase_id: order.id}}).success(function(order_instance) {
        if (order_instance) {
          // order already exists, do nothing
          callback();
        } else {
          // build instance and save
            var new_order_instance = Order.build({
            coinbase_id: order.id,
            amount: order.total_btc.cents / 100000000, // convert satoshis to BTC
            time: order.created_at
          });
            new_order_instance.save().success(function() {
            callback();
          }).error(function(err) {
            callback(err);
          });
        }
      });
    }
  };
  </code></pre>