Reputation: 647
I want to write my HTML in HTML. Not some fancy way. The only thing that would be cool is to be able to use some sort of include
statement to include header/navigation/footer for each page.
I've looked at pug, ejs, mustache, nunchuck, etc etc. I hate all of these things. I just want to write HTML..
What is a simple node module to do this? And how do I set up the render engine in my main app.js
? I am using express
Upvotes: 0
Views: 95
Reputation: 310
Looks like you want to server only static html files using node not some jsp equivalent dynamically generated html. Express has support for serving static files and you do not need to define any routes for that! http://expressjs.com/en/starter/static-files.html
Second thing I understood from your post is you want to include some common html to your html page. One way of doing that is to use a browser/client side java script framework. Take a look at angular.js. It has ng-include. Basically you can include one html file to another using that.
Upvotes: 0
Reputation: 5637
You can just set up your express routes to connect with html
pages. Here's a simple example:
var express = require('express');
// Create express app
var app = express();
// Route index page to an index html page
app.get('/', function(req, res){
res.sendFile(__dirname + '/path/to/views/index.html');
});
// Create server
app.listen(8080, function(){
console.log('Ready on port 8080...');
});
As a side note, ejs
is basically html
but with some bonus functionality. You can totally get away with writing only html
in ejs
pages and then start using the ejs
features when you get comfortable with it.
Upvotes: 2