Skip to content

Commit d5581f3

Browse files
committed
First public implementation of the "Beardless сustomizable template engine, Mr. Jt for Node.js and Web browsers."
1 parent 21cc157 commit d5581f3

38 files changed

+4559
-0
lines changed

.babelrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets":
3+
[
4+
[
5+
"@babel/preset-env", {
6+
"targets": {
7+
"node": "current"
8+
}
9+
}
10+
]
11+
]
12+
}

License.txt

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

Readme.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
2+
# Mr. [Jt 🎩](https://github.com/3F/Jt)
3+
4+
Meet beardless сustomizable template engine, Mr. Jt for Node.js and Web browsers.
5+
6+
[![release-src](https://img.shields.io/github/release/3F/Jt.svg)](https://github.com/3F/Jt/releases/latest)
7+
[![License](https://img.shields.io/badge/License-MIT-74A5C2.svg)](https://github.com/3F/Jt/blob/master/License.txt)
8+
9+
**Download:**
10+
* Stable: [/releases](https://github.com/3F/Jt/releases) [ [latest](https://github.com/3F/Jt/releases/latest) ]
11+
* CI builds: [`/artifacts` page](https://ci.appveyor.com/project/3Fs/jt/history) or find as `Pre-release` with mark `🎲 Nightly build` on [GitHub Releases](https://github.com/3F/Jt/releases) page.
12+
13+
```javascript
14+
jt.use('', 'Hello %p% world')
15+
.as({ p: 'amazing'})
16+
.reset().as({ p: 'crazy'});
17+
```
18+
19+
```javascript
20+
jt.use('s1', 'Today is a {( a < b )} good {/} bad {;} day!')
21+
.sa(jtif, { a: 5, b: 7})
22+
.value()
23+
```
24+
25+
## Why Jt ?
26+
27+
Extremely small, fast, and damn customizable. Okay, Let's see what's going on:
28+
29+
### Speed 🚀
30+
31+
Only **native** lower-level implementation. Even for conditional statements, like:
32+
33+
```
34+
{( d > 5 )} yes {/} no {;}
35+
```
36+
37+
Which do **not** uses `regex`, or `eval()`, or `new Function()`, ... Feel the speed.
38+
39+
### Size 📦
40+
41+
Extra small size. Just about o-n-e kilobyte of fully workable core engine:
42+
* ~ **1.02 KB** for Core of ES6 gzipped;
43+
* ~ 1.09 KB for Core of **ES3** gzipped;
44+
45+
Same things for custom handlers.
46+
47+
### Configurable 🔧
48+
49+
You can configure, add, or change anything!
50+
51+
Jt was designed to be loyal to your preferences *on the fly*. Maybe for this:
52+
53+
```javascript
54+
jt.use('s1', 'Good {{p}}, $p -p- !')
55+
.as({ p: 'Jt' })
56+
.as({ p: 'Mr.' }, {op: '$'})
57+
.as({ p: 'morning' }, '{{}}')
58+
.val(),
59+
```
60+
61+
Or for this:
62+
63+
```javascript
64+
65+
// {( true )} yes {/} no {;} -> {if( true )} yes {else} no {endif}
66+
67+
jt.use('legacy', '{if( true )} yes {else} no {endif}!')
68+
.sa(new JtIfHandler([ '{}' ],
69+
{
70+
if: 'if',
71+
else: 'else',
72+
fi: 'endif',
73+
}))
74+
.val() // yes !
75+
```
76+
77+
Or for something more ...
78+
79+
### Extensible via Pluginable handlers 🗃
80+
81+
Sure! Add or change any features for the layers, still *on the fly*.
82+
83+
Do you need something special? No problem, just implement [IJtHandler](src/Handlers/IJtHandler.ts) to cover your awesome things. It easy.
84+
85+
### Comfy but strong 🌇
86+
87+
Changeable layers through common chain will make you happy.
88+
89+
You can control everything just in a few steps:
90+
91+
```javascript
92+
jt.use('hello', 'Hello you from $tip, dear $name.')
93+
.as({ tip: 'Jt', name: 'John' }); // Hello you from Jt, dear John.
94+
95+
// ...
96+
97+
jt.use('hello')
98+
.as(-1, true)
99+
.as({ name: 'Denis' }) // Hello you from Jt, dear Denis.
100+
.reset()
101+
.as({ tip: 'Moscow' })
102+
.eject((v) => t.is(v, 'Hello you from Moscow, dear $name.'))
103+
...
104+
.as({ name: '{( r > 100 )}friend{/}visitor{;}' })
105+
.sa(jtif, { r: actual })
106+
...
107+
.val();
108+
🐧
109+
```
110+
111+
### Stability 🗠
112+
113+
Clean [API](src/Core/) and its [tests](tests/) will take care of your peace of mind.
114+
115+
### Compatibility 🗸
116+
117+
Nothing special, we just provide separate ES3+/ES6+ support in Node.js and Web browsers environment. Choose more suitable package for your case.
118+
119+
### No dependencies to something 👐
120+
121+
Developed from scratch without dependencies to something.
122+
123+
### Open and Free 🍰
124+
125+
MIT License, Enjoy!
126+
127+
## License
128+
129+
Licensed under the [MIT License (MIT)](https://github.com/3F/Jt/blob/master/License.txt)
130+
131+
```
132+
Copyright (c) 2019 Denis Kuzmin < entry.reg@gmail.com > GitHub/3F
133+
```
134+
135+
[ [ ☕ Donate ](https://3F.github.com/Donation/) ]
136+
137+
## API
138+
139+
* Core: [IJt](https://github.com/3F/Jt/blob/master/src/Core/IJt.ts)[IJtAct](https://github.com/3F/Jt/blob/master/src/Core/IJtAct.ts)
140+
* Configuration: [IJtConfig](https://github.com/3F/Jt/blob/master/src/Core/IJtConfig.ts)
141+
* Handlers: [IJtHandler](https://github.com/3F/Jt/blob/master/src/Handlers/IJtHandler.ts)
142+
143+
## Versions
144+
145+
TODO:
146+
147+
## Build & Tests
148+
149+
```
150+
npm install
151+
gulp build --conf debug
152+
```
153+
154+
Available tests can be raised by command:
155+
156+
```
157+
npm test
158+
```
159+
160+
We're waiting for your awesome contributions!

ava.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default
2+
{
3+
"files": [
4+
"./tests/*.js",
5+
],
6+
"verbose": false,
7+
}

gulpfile.babel.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright (c) 2019 Denis Kuzmin < entry.reg@gmail.com > GitHub/3F
3+
*/
4+
5+
import { src, dest, series, parallel } from 'gulp'
6+
import { cfg } from './tasks/config'
7+
8+
import gclean from 'gulp-clean'
9+
import { Jt } from './tasks/Jt'
10+
import { JtHandlers } from './tasks/JtHandlers'
11+
import { distr } from './tasks/distr'
12+
13+
14+
exports.build = series
15+
(
16+
clean,
17+
parallel(
18+
Jt,
19+
JtHandlers,
20+
),
21+
distr
22+
);
23+
exports.clean = clean;
24+
25+
function clean()
26+
{
27+
return src([cfg.dir.out, cfg.dir.obj, cfg.dir.zipped], {
28+
allowEmpty: true,
29+
read: false
30+
})
31+
.pipe(gclean());
32+
}
33+
34+
exports.default = function(cb)
35+
{
36+
console.log
37+
(
38+
"Usage:\n\n" +
39+
" gulp build --conf (release|debug*)\n" +
40+
" gulp clean\n" +
41+
"\n" +
42+
"gulp --tasks\n"
43+
);
44+
cb();
45+
}

header

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Jt $version$ https://github.com/3F/Jt
2+
"Beardless сustomizable template engine, Mr. Jt"
3+
Copyright (c) 2019 Denis Kuzmin < entry.reg@gmail.com > GitHub/3F
4+
The MIT License*/

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
3+
const jtcore = require('./Core/Jt.es6.ncc');
4+
5+
exports.Jt = jtcore.Jt;
6+
exports.JtAct = jtcore.JtAct;
7+
exports.JtConfig = jtcore.JtConfig;
8+
9+
10+
// JtIfHandler
11+
12+
exports.JtIfHandler = require('./Handlers/JtIfHandler.es6.ncc');

package.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "jt",
3+
"version": "1.0.0",
4+
"description": "Beardless сustomizable template engine, Mr. Jt for Node.js and Web browsers.",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "ava"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/3F/Jt.git"
12+
},
13+
"keywords": [
14+
"template",
15+
"template-engine",
16+
"templater",
17+
"Jt",
18+
"Mr.Jt",
19+
"JavaScript",
20+
"TypeScript"
21+
],
22+
"author": "Denis Kuzmin [ entry.reg@gmail.com ] GitHub/3F",
23+
"license": "MIT",
24+
"bugs": {
25+
"url": "https://github.com/3F/Jt/issues"
26+
},
27+
"homepage": "https://github.com/3F/Jt#readme",
28+
"devDependencies": {
29+
"@babel/core": "^7.4.4",
30+
"@babel/preset-env": "^7.4.4",
31+
"@babel/register": "^7.4.4",
32+
"ava": "^1.4.1",
33+
"browserify": "^16.2.3",
34+
"git-repo-info": "^2.1.0",
35+
"google-closure-compiler": "^20190121.0.0",
36+
"gulp": "^4.0.2",
37+
"gulp-append-prepend": "^1.0.8",
38+
"gulp-babel": "^8.0.0",
39+
"gulp-clean": "^0.4.0",
40+
"gulp-if": "^2.0.2",
41+
"gulp-rename": "^1.4.0",
42+
"gulp-replace": "^1.0.0",
43+
"gulp-sourcemaps": "^2.6.5",
44+
"gulp-typescript": "^5.0.1",
45+
"gulp-zip": "^4.2.0",
46+
"minimist": "^1.2.0",
47+
"through2": "^3.0.1",
48+
"tsify": "^4.0.1",
49+
"typescript": "^3.4.5",
50+
"vinyl-buffer": "^1.0.1",
51+
"vinyl-source-stream": "^2.0.0"
52+
}
53+
}

0 commit comments

Comments
 (0)