Templating with Swig & Express

Express is a minimal and flexible Node.js web application framework. To install: npm install express --save Swig is a simple, powerful, and extendable JavaScript Template Engine. To install: npm install swig --save In this lines we are registering our swig engine in express as html and specifying our template directory application.engine('html', swig.renderFile) application.set('view engine', 'html') application.set('views', __dirname + '/views') We can configure cache in our application as follows: application.set('view cache', false) swig. [Read More]

Mongoose

Mongoose allows us to have access to the MongoDB commands, to include mongoose library type in your terminal: npm install mongoose --save In order to use mongoose in your js, you need: //Grab it in our project var mongoose = require('mongoose') //Connect to a MongoDB database mongoose.connect('mongodb://localhost/mongoosedb') //Create an Schema (is what is used to define attributes for our documents) var Schema = mongoose.Schema //A model using it var Person = mongoose. [Read More]

Inquirer & Callback

Inquirer.js strives to be an easily embeddable and beautiful command line interface for Node.js Inquirer.js should ease the process of: Providing error feedback Asking questions Parsing input Validating answers Managing hierarchical prompts In order to install inquirer type in your terminal: npm install inquirer --save Usage prompt functionality: var inquirer = require("inquirer"); inquirer.prompt([/* Pass your questions in here */], function( answers ) { // Use user feedback for... whatever!! }) Let’s consider the following code: [Read More]

Parsing Json with Ajax

We want to consume a GET service and parsing an JSON response using Ajax and JQuery, so here is what we need. JSON example: { uuid: "7d6bc74b9a33257e29bb0206e2b00f434deb51a0", nombre: "Jose Luis", apellidoPaterno: "De la Cruz", apellidoMaterno: "Morales", rfc: "rfc", fechaNacimiento: 1445640529000, 18 moreā€¦ } Let’s imagine this scenario: when user type rfc in a form and click on send button, we consume our service retrieve an JSON and fill some input text fields in a form, so our html file looks like this: [Read More]

UX Development

In this section I will post all referent about UX development such as Javascript, CSS and HTML5 specs.

Return to the main article