HTML Element Interpolation with Pug

Watch out! This tutorial is over 6 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.

Further to our previous tutorial, sometimes it may be necessary to nest HTML tags inside of each other. Element interpolation with Pug is done in a syntax similar to variable interpolation; square brackets instead of curly braces are used here.

Continue reading

Getting started with Pug template engine

Watch out! This tutorial is over 6 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.

Clean and organized HTML is what Front-end Developers always aim for. Well with Pug (formerly known as “Jade” ),  a high performance and feature-rich templating engine, that’s easy to achieve. Simply put, Pug is a clean, white space/indentation sensitive syntax for writing html.

Continue reading

Node.js Events

Watch out! This tutorial is over 6 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.

Every action on a computer is an event. Like when a connection is made or a file is opened, for example. Node.js is perfect for event-driven applications because objects in Node.js can fire events, like the readStream object fires events when opening and closing a file.

Continue reading

Create a WordPress Post from Node.js

Watch out! This tutorial is over 7 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.

WordPress uses an XML-RPC interface by default. XML-RPC is a remote procedure call (RPC) protocol which uses XML to encode its calls and HTTP as a transport mechanism. With WordPress XML-RPC support, you can post to your WordPress blog using many popular clients. You could even consider writing your own client application using Node.js. Let’s do a proof of concept.

Continue reading

Saving Data to MongoDB Database from a Node.js Application

Watch out! This tutorial is over 7 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.

In this tutorial we will be creating a very simple Node application, that will allow users to input data that they want to store in a MongoDB database. You can use the the existing template in XenServer to launch a Linux machine with Node.js and MongoDB pre-installed.

Continue reading

Hello World in Node.js

Watch out! This tutorial is over 7 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.

This is how you would script “Hello World” in Node.js

// requiring the HTTP interfaces in node 
var http = require('http'); 

// create an http server to handle requests and response 
http.createServer(function (req, res) 
{ 

  // sending a response header of 200 OK 
  res.writeHead(200, {'Content-Type': 'text/plain'}); 

  // print out Hello World 
  res.end('Hello World\n'); 

// use port 8080
}).listen(8080); 

console.log('Server running on port 8080.');