|
| 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 | +[](https://github.com/3F/Jt/releases/latest) |
| 7 | +[](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 < [email protected] > 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! |
0 commit comments