File: README.md

package info (click to toggle)
node-utml 0.2.0~gite9f7c3d-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 112 kB
  • ctags: 14
  • sloc: makefile: 2; sh: 2
file content (54 lines) | stat: -rw-r--r-- 959 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
UTML: Underscore Template Markup Language
=========================================

UTML is a wrapper around the underscore.js template method to make it comply with the express web framework.

## Installing

Use npm:

	npm install utml

## Using it in your project

Setting up your express app

	// no need to require utml, express will do that for us
	var app = require('express').createServer();
	
	// set utml as the view engine
	app.set('view engine', 'utml');
	
	
	app.get('/', function(req, res){
		res.render('index', {
			locals : { 
				pageTitle : "Hello Node.js + Express + UTML!!",
				msg : "Insert snarky message here."
			}
		});
	});
	
	// start listening on the specified port
	app.listen(8000);

Create 'views/index.utml'

	<p><%= msg %></p>

Create 'views/layout.utml'

	<!doctype html>
	<html>
		<head>
			<title>Node Test Suite</title>
		</head>
		<body>
	
			<h1><%= pageTitle %></h1>
	
			<div><%= body %></div>
	
		</body>
	</html>