Using HTML in Express instead of Jade
You can do it this way:
Install ejs:
npm install ejs
Set your template engine in app.js as ejs
// app.jsapp.engine('html', require('ejs').renderFile);app.set('view engine', 'html');
Now in your route file you can assign template variables
// ./routes/index.jsexports.index = function(req, res){res.render('index', { title: 'ejs' });};
Then you can create your html view in /views directory.
Jade also accepts html input.
Just add a dot to the end of line to start submitting pure html.
If that does the trick for you then try:
doctype html html. // THAT DOT <body> <div>Hello, yes this is dog</div> </body>
PS - No need to close HTML - that's done automagically by Jade.
As of express 3 you can simply use response.sendFile
app.get('/', function (req, res) { res.sendfile(__dirname + '/index.html');});)
From the official express api reference:
res.sendfile(path, [options], [fn]])
Transfer the file at the given path.
Automatically defaults the Content-Type response header field based on the filename's extension. The callback
fn(err)
is invoked when the transfer is complete or when an error occurs.
Warning
res.sendFile
provides client-side cache through http cache headers but it does not cache file contents on server-side. The code above will hit the disk on each request.