Skip to content

Commit 1f5bf65

Browse files
committed
To GitHub
1 parent 0002ef7 commit 1f5bf65

File tree

8 files changed

+92
-4
lines changed

8 files changed

+92
-4
lines changed

MIT-LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2011 Viacheslav Lotsmanov (unclechu)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

Readme.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#nJSt (Native JavaScript Templates) v0.1
2+
3+
### Installing
4+
5+
git clone git://github.com/unclechu/njst njst
6+
7+
# USAGE
8+
9+
### HTML page.html
10+
11+
<html>
12+
<head>
13+
<title>#{PageTitle}</title>
14+
</head>
15+
16+
<body>
17+
<h1>#{PageTitle}</h1>
18+
19+
<# for (var i=0; i<List.length; i++) {
20+
#><li><#
21+
if (typeof List[i] !== 'object') {
22+
show(List[i]);
23+
} else {
24+
show(List[i].name +' - '+ List[i].note);
25+
}
26+
#></li><#
27+
} #>
28+
</body>
29+
</html>
30+
31+
### Node.JS test.js
32+
33+
var njst = require('./njst');
34+
var fs = require('fs');
35+
var http = require('http');
36+
37+
http.createServer(function (request, response) {
38+
fs.readFile('./page.html', function (err, data) {
39+
if (err) return;
40+
var out;
41+
var context = {
42+
PageTitle: 'jJSt demonstration #1',
43+
List: ['First', {name:'Second', note:'2th'}, 'Third'],
44+
};
45+
46+
out = njst.parse(data, context, {debug:1});
47+
response.writeHead(200, {'content-type':'text/html; charset=utf-8'});
48+
response.end(out);
49+
});
50+
}).listen(8000);
51+
52+
## Author
53+
54+
Viacheslav Lotsmanov (unclechu)

examples/demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var fs = require('fs');
33
var http = require('http');
44

55
http.createServer(function (request, response) {
6-
fs.readFile('../templates/demo.html', function (err, data) {
6+
fs.readFile('./templates/demo.html', function (err, data) {
77
if (err) return;
88

99
var out;

examples/demo2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var fs = require('fs');
33
var http = require('http');
44

55
http.createServer(function (request, response) {
6-
fs.readFile('../templates/demo2.html', function (err, data) {
6+
fs.readFile('./templates/demo2.html', function (err, data) {
77
if (err) return;
88

99
var out;
File renamed without changes.
File renamed without changes.

lib/njst.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Author: Viacheslav Lotsmanov (unclechu)
66
77
Blog: unclechumind.blogspot.com
88
9-
MIT License: http://www.opensource.org/licenses/mit-license.php
10-
119
Copyright (c) 2011 Viacheslav Lotsmanov (unclechu)
1210
1311
Permission is hereby granted, free of charge, to any person obtaining a copy of

package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "nJSt",
3+
"description": "Native JavaScript Templates",
4+
"version": "0.1",
5+
"author": "Viacheslav Lotsmanov (unclechu)",
6+
"repository": {
7+
"type": "git",
8+
"url": "http://github.com/unclechu/njst.git"
9+
},
10+
"directories": {
11+
"lib": "./lib"
12+
},
13+
"engines": {
14+
"node": ">= 0.5.0"
15+
},
16+
"main": "lib/njst"
17+
}

0 commit comments

Comments
 (0)