I want to setup an application where I can write as much html over jade as possible. I don't dislike jade, I just want to write html/angular/node APIs, since I'm learning a lot of technologies at once (angular, node, jade, etc).
I would like to build a skeleton project like the following:
Static (server built pages using jade or html) for SEO (basic business card pages). i.e. sitename.com/about, sitename.com/
angular driven admin area (i.e. sitename.com/admin), that is a single html file with embedded angular views/partials.
Should I just learn jade, or attempt to use this mixed approach? I have the first part (simple jade static pages).
Some popular template engines that work with Express are Pug, Mustache, and EJS. The Express application generator uses Jade as its default, but it also supports several others. See Template Engines (Express wiki) for a list of template engines you can use with Express.
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.
Template engines are used when you want to rapidly build web applications that are split into different components. Templates also enable fast rendering of the server-side data that needs to be passed to the application. For example, you might want to have components such as body, navigation, footer, dashboard, etc.
Express is pretty template-agnostic, in that you can choose any templating engine you like. If you want more HTML-style templates, you could use ejs instead of Jade, for instance:
// install ejs first
npm install ejs
// app.js
var express = require('express');
var app = express();
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.get('/', function(req, res) {
res.render('index', { name : 'World' });
});
app.listen(3012);
// ./views/index.html
<h1>Hello <%= name %>!</h1>
// Output:
<h1>Hello World!</h1>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With