22
33## Contents
44
5- - [ Demo] ( #demo )
5+ - [ Demo] ( https://blueimp.github.io/JavaScript-Templates/ )
66- [ Description] ( #description )
77- [ Usage] ( #usage )
88 - [ Client-side] ( #client-side )
2222- [ Tests] ( #tests )
2323- [ License] ( #license )
2424
25- ## Demo
26-
27- [ JavaScript Templates Demo] ( https://blueimp.github.io/JavaScript-Templates/ )
28-
2925## Description
3026
31271KB lightweight, fast & powerful JavaScript templating engine with zero
32- dependencies. Compatible with server-side environments like Node.js, module
33- loaders like RequireJS, Browserify or webpack and all web browsers.
28+ dependencies.
29+ Compatible with server-side environments like [ Node.js] ( https://nodejs.org/ ) ,
30+ module loaders like [ RequireJS] ( https://requirejs.org/ ) or
31+ [ webpack] ( https://webpack.js.org/ ) and all web browsers.
3432
3533## Usage
3634
3735### Client-side
3836
37+ Install the ** blueimp-tmpl** package with [ NPM] ( https://www.npmjs.org/ ) :
38+
39+ ``` sh
40+ npm install blueimp-tmpl
41+ ```
42+
3943Include the (minified) JavaScript Templates script in your HTML markup:
4044
4145``` html
@@ -77,7 +81,7 @@ var data = {
7781```
7882
7983In a real application, this data could be the result of retrieving a
80- [ JSON] ( http ://json.org/) resource.
84+ [ JSON] ( https ://json.org/) resource.
8185
8286Render the result by calling the ** tmpl()** method with the id of the template
8387and the data object as arguments:
@@ -89,10 +93,9 @@ document.getElementById('result').innerHTML = tmpl('tmpl-demo', data)
8993### Server-side
9094
9195The following is an example how to use the JavaScript Templates engine on the
92- server-side with [ node .js] ( http ://nodejs.org/) .
96+ server-side with [ Node .js] ( https ://nodejs.org/) .
9397
94- Create a new directory and add the ** tmpl.js** file. Or alternatively, install
95- the ** blueimp-tmpl** package with [ npm] ( https://www.npmjs.org/ ) :
98+ Install the ** blueimp-tmpl** package with [ NPM] ( https://www.npmjs.org/ ) :
9699
97100``` sh
98101npm install blueimp-tmpl
@@ -116,7 +119,7 @@ Add a file **server.js** with the following content:
116119
117120``` js
118121require (' http' )
119- .createServer (function (req , res ) {
122+ .createServer (function (req , res ) {
120123 var fs = require (' fs' ),
121124 // The tmpl module exports the tmpl() function:
122125 tmpl = require (' ./tmpl' ),
@@ -129,7 +132,7 @@ require('http')
129132 features: [' lightweight & fast' , ' powerful' , ' zero dependencies' ]
130133 }
131134 // Override the template loading method:
132- tmpl .load = function (id ) {
135+ tmpl .load = function (id ) {
133136 var filename = id + ' .html'
134137 console .log (' Loading ' + filename)
135138 return fs .readFileSync (filename, ' utf8' )
@@ -295,7 +298,7 @@ function, e.g. with the following code:
295298
296299``` js
297300var originalFunc = tmpl .func
298- tmpl .func = function (s , p1 , p2 , p3 , p4 , p5 , offset , str ) {
301+ tmpl .func = function (s , p1 , p2 , p3 , p4 , p5 , offset , str ) {
299302 if (p1 && / \s / .test (p1)) {
300303 if (
301304 ! offset ||
@@ -386,9 +389,9 @@ The JavaScript Templates project comes with a compilation script, that allows
386389you to compile your templates into JavaScript code and combine them with a
387390minimal Templates runtime into one combined JavaScript file.
388391
389- The compilation script is built for [ node .js] ( http ://nodejs.org/) .
392+ The compilation script is built for [ Node .js] ( https ://nodejs.org/) .
390393To use it, first install the JavaScript Templates project via
391- [ npm ] ( https://www.npmjs.org/ ) :
394+ [ NPM ] ( https://www.npmjs.org/ ) :
392395
393396``` sh
394397npm install blueimp-tmpl
@@ -425,7 +428,7 @@ There are two different ways to run the tests:
425428- run ` npm test ` in the Terminal in the root path of the repository package.
426429
427430The first one tests the browser integration, the second one the
428- [ node .js] ( http ://nodejs.org/) integration.
431+ [ Node .js] ( https ://nodejs.org/) integration.
429432
430433## License
431434
0 commit comments