Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a index.jade file?

Trying to learn HTML5 and downloaded a test project https://github.com/amiklosi/Comicr. There is a folder named views with a index.jade which I suppose is the start page. What does it take to run that type of files? I can not open it directly in the browser.

like image 614
Xtreme Avatar asked Jan 08 '12 15:01

Xtreme


People also ask

How do I open a jade file?

All jade files need to be transformed in the HTML. Also don't forget that you need to install other dependencie like express, nodemailer, etc (see requires in the source code). And the application should by available on http://localhost/3000. All Jade templates will be correctly rendered and displayed as HTML.

What is Jade file?

Jade is a template engine for node. js and the default rendering engine for the Express web framework. It is a new, simplified language that compiles into HTML and is extremely useful for web developers. Jade is designed primarily for server-side templating in node.

What is Jade code?

Program structure. JADE programs are developed using a user interface that allows programmers to visually create classes and define their properties and methods. Instead of locating methods in large files, programmers select the method they would like to edit and only the code for that particular method is displayed.


2 Answers

jade is a HTML templating engine. All jade files need to be transformed in the HTML.

You need to install to install jade by running

npm install jade

Also don't forget that you need to install other dependencie like express, nodemailer, etc (see requires in the source code).

Then run the app using

node app.js

And the application should by available on http://localhost/3000. All Jade templates will be correctly rendered and displayed as HTML.

like image 86
kubetz Avatar answered Oct 18 '22 03:10

kubetz


You create a app.js file with the following contents.

var express = require('express')
var app = module.exports = express.createServer();

app.configure(function(){
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
});

app.get('/', function(){
    res.render('index', {option: 'value'});
});
like image 2
Fabián Heredia Montiel Avatar answered Oct 18 '22 02:10

Fabián Heredia Montiel