|
3 | 3 | Web Template Engine - Neutral TS
|
4 | 4 | ================================
|
5 | 5 |
|
6 |
| -Neutral TS is a **safe, modular, language-agnostic template engine** built in Rust. |
7 |
| -It works as a **native Rust library** or via **IPC** for other languages like Python and PHP. |
8 |
| -With Neutral TS you can reuse the **same template across multiple languages** with consistent results. |
| 6 | +Neutral TS is a **safe, modular, language-agnostic template engine** built in Rust. It works as a **native Rust library** or via **IPC** for other languages like Python and PHP. With Neutral TS you can reuse the **same template across multiple languages** with consistent results. |
9 | 7 |
|
10 |
| -For non-Rust requires an IPC server that you can download from the [IPC repository](https://github.com/FranBarInstance/neutral-ipc) - [IPC server](https://github.com/FranBarInstance/neutral-ipc/releases). Alternatively in Python you can use [PYPI Package](https://pypi.org/project/neutraltemplate/) |
| 8 | +Examples for [Rust](https://github.com/FranBarInstance/neutralts-docs/tree/master/examples/rust), [Python](https://github.com/FranBarInstance/neutralts-docs/tree/master/examples/python), [PHP](https://github.com/FranBarInstance/neutralts-docs/tree/master/examples/php), [Node.js](https://github.com/FranBarInstance/neutralts-docs/tree/master/examples/node) and [Go](https://github.com/FranBarInstance/neutralts-docs/tree/master/examples/go) here: [download](https://github.com/FranBarInstance/neutralts-docs/releases). All PWA [examples](https://github.com/FranBarInstance/neutralts-docs/tree/master/examples) use the same template: [Neutral templates](https://github.com/FranBarInstance/neutralts-docs/tree/master/examples/neutral). |
11 | 9 |
|
12 |
| -The documentation of the **web template** engine is here: [template engine doc](https://franbarinstance.github.io/neutralts-docs/docs/neutralts/doc/) and **Rust** documentation here: [rust doc](https://docs.rs/neutralts/latest/neutralts/). |
| 10 | +The documentation of the **web template** engine is here: [template engine doc](https://franbarinstance.github.io/neutralts-docs/docs/neutralts/doc/) and **Rust** documentation here: [Rust doc](https://docs.rs/neutralts/latest/neutralts/). |
13 | 11 |
|
14 | 12 | Template Engine - Features
|
15 | 13 | --------------------------
|
@@ -39,17 +37,45 @@ It allows you to create templates compatible with any system and any programming
|
39 | 37 | How it works
|
40 | 38 | ------------
|
41 | 39 |
|
42 |
| -Neutral TS template engine offers two main ways to integrate with other programming languages: |
| 40 | +Neutral TS supports two integration approaches: |
43 | 41 |
|
44 |
| -* In Rust: You can use Neutral TS template engine as a library by downloading the crate. |
| 42 | +### **Available Modes:** |
| 43 | +- **Rust**: Native library (crate) |
| 44 | +- **Python**: Native package **or** IPC client + IPC server |
| 45 | +- **Other languages** (PHP, etc.): IPC client + IPC server required |
45 | 46 |
|
46 |
| -* In other programming languages: Inter-Process Communication ([IPC](https://gitlab.com/neutralfw/ipc)) is necessary, similar to how databases like MariaDB work. |
| 47 | +### **The MySQL Analogy (IPC architecture):** |
| 48 | +Uses the exact same client-server mechanism as a database: |
47 | 49 |
|
48 |
| -Imagine a database. It has a server, and different programming languages access the data through a client. This means that if you run a "SELECT ..." query from any programming language, the result will always be the same. |
| 50 | +**MySQL:** |
| 51 | +- TCP server that receives SQL queries |
| 52 | +- Processes queries internally |
| 53 | +- Returns results to the client |
49 | 54 |
|
50 |
| -Similarly, Neutral TS has an IPC server, and each programming language has a client. No matter where you run the template, the result will always be the same. |
| 55 | +**Neutral TS:** |
| 56 | +- TCP server that receives templates + JSON data |
| 57 | +- Processes templates internally |
| 58 | +- Returns rendered HTML to the client |
| 59 | + |
| 60 | +### **Why It Works:** |
| 61 | +- **Same principle**: Lightweight client + Powerful server |
| 62 | +- **Universal protocol**: TCP + text/JSON (supported by all languages) |
| 63 | +- **Consistent results**: Same engine processes everything, guaranteeing identical output |
| 64 | + |
| 65 | +### **Security Advantage:** |
| 66 | +The IPC architecture provides important security benefits: |
| 67 | +- **Sandboxed execution**: Templates run in isolated processes |
| 68 | +- **Reduced attack surface**: Main application protected from template engine vulnerabilities |
| 69 | +- **Resource control**: Memory and CPU limits can be enforced at server level |
| 70 | +- **Crash containment**: Template engine failures don't affect the main application |
| 71 | + |
| 72 | +### **Key Advantage:** |
| 73 | +Just like an SQL query returns the same data from any language, a Neutral TS template returns the same HTML from Python, PHP, Rust... with added security isolation. |
| 74 | + |
| 75 | +### **IPC Components:** |
| 76 | +- **IPC Server**: Universal standalone application (written in Rust) for all languages - download from: [IPC Server](https://github.com/FranBarInstance/neutral-ipc/releases) |
| 77 | +- **IPC Clients**: Language-specific libraries to include in your project - available at: [IPC Clients](https://github.com/FranBarInstance/neutral-ipc/tree/master/clients) |
51 | 78 |
|
52 |
| -Thanks to this, and to its modular and parameterizable design, it is possible to create utilities or plugins that will work everywhere. For example, you can develop tools to create forms or form fields and create your own libraries of "snippets" for repetitive tasks. |
53 | 79 |
|
54 | 80 | Localization
|
55 | 81 | ------------
|
@@ -443,113 +469,13 @@ let status_param = template.get_status_param();
|
443 | 469 | // act accordingly at this point according to your framework
|
444 | 470 | ```
|
445 | 471 |
|
446 |
| -### Rust examples |
447 |
| - |
448 |
| - - [PWA example](https://gitlab.com/neutralfw/neutralts/-/tree/master/web-app/rust) |
449 |
| - - [actix-web](https://gitlab.com/neutralfw/neutralts/-/tree/master/examples/actix) |
450 |
| - - [warp](https://gitlab.com/neutralfw/neutralts/-/tree/master/examples/warp) |
451 |
| - - [axum](https://gitlab.com/neutralfw/neutralts/-/tree/master/examples/actix) |
452 |
| - - [rocket](https://gitlab.com/neutralfw/neutralts/-/tree/master/examples/rocket) |
453 |
| - - [examples](https://gitlab.com/neutralfw/neutralts/-/tree/master/examples) |
454 |
| - |
455 |
| -Python - Package |
456 |
| ----------------- |
457 |
| - |
458 |
| -```text |
459 |
| -pip install neutraltemplate |
460 |
| -``` |
461 |
| - |
462 |
| -```text |
463 |
| -from neutraltemplate import NeutralTemplate |
464 |
| -
|
465 |
| -template = NeutralTemplate("file.ntpl", schema) |
466 |
| -contents = template.render() |
467 |
| -
|
468 |
| -# e.g.: 200 |
469 |
| -status_code = template.get_status_code() |
470 |
| -
|
471 |
| -# e.g.: OK |
472 |
| -status_text = template.get_status_text() |
473 |
| -
|
474 |
| -# empty if no error |
475 |
| -status_param = template.get_status_param() |
476 |
| -
|
477 |
| -# act accordingly at this point according to your framework |
478 |
| -``` |
479 |
| - |
480 |
| -Python - IPC |
481 |
| ------------- |
482 |
| - |
483 |
| -Requires an IPC server that you can download from the [repository](https://github.com/FranBarInstance/neutral-ipc), and an IPC client that you can download here: [IPC client](https://gitlab.com/neutralfw/ipc/-/tree/master/python) |
484 |
| - |
485 |
| -```text |
486 |
| -from NeutralIpcTemplate import NeutralIpcTemplate |
487 |
| -
|
488 |
| -template = NeutralIpcTemplate("file.ntpl", schema) |
489 |
| -contents = template.render() |
490 |
| -
|
491 |
| -# e.g.: 200 |
492 |
| -status_code = template.get_status_code() |
493 |
| -
|
494 |
| -# e.g.: OK |
495 |
| -status_text = template.get_status_text() |
496 |
| -
|
497 |
| -# empty if no error |
498 |
| -status_param = template.get_status_param() |
499 |
| -
|
500 |
| -# act accordingly at this point according to your framework |
501 |
| -``` |
502 |
| - |
503 |
| -### Python examples |
504 |
| - |
505 |
| -- [PWA example IPC](https://gitlab.com/neutralfw/neutralts/-/tree/master/web-app/python) |
506 |
| -- [PWA example Package](https://github.com/FranBarInstance/neutraltemplate/tree/master/examples) |
507 |
| -- [Simple example](https://gitlab.com/neutralfw/neutralts/-/tree/master/examples/python) |
508 |
| -- [PYPI Package](https://pypi.org/project/neutraltemplate/) |
509 |
| -- [IPC client](https://gitlab.com/neutralfw/ipc/-/tree/master/python) |
510 |
| -- [IPC server](https://github.com/FranBarInstance/neutral-ipc) |
511 |
| - |
512 |
| -PHP |
513 |
| ---- |
514 |
| - |
515 |
| -Requires an IPC server that you can download from the [repository](https://github.com/FranBarInstance/neutral-ipc), and an IPC client that you can download here: [IPC client](https://gitlab.com/neutralfw/ipc/-/tree/master/php) |
516 |
| - |
517 |
| -```text |
518 |
| -include 'NeutralIpcTemplate.php'; |
519 |
| -
|
520 |
| -$template = new NeutralIpcTemplate("file.ntpl", $schema); |
521 |
| -$contents = $template->render(); |
522 |
| -
|
523 |
| -// e.g.: 200 |
524 |
| -$status_code = $template->get_status_code(); |
525 |
| -
|
526 |
| -// e.g.: OK |
527 |
| -$status_text = $template->get_status_text(); |
528 |
| -
|
529 |
| -// empty if no error |
530 |
| -$status_param = $template->get_status_param(); |
531 |
| -
|
532 |
| -// act accordingly at this point according to your framework |
533 |
| -``` |
534 |
| - |
535 |
| -### PHP examples |
536 |
| - |
537 |
| -- [PWA example](https://gitlab.com/neutralfw/neutralts/-/tree/master/web-app/php) |
538 |
| -- [example](https://gitlab.com/neutralfw/neutralts/-/tree/master/examples/php) |
539 |
| -- [IPC client](https://gitlab.com/neutralfw/ipc/-/tree/master/php) |
540 |
| -- [IPC server](https://gitlab.com/neutralfw/ipc) |
541 |
| - |
542 |
| -Links |
543 |
| ------ |
544 |
| - |
545 | 472 | Neutral TS template engine.
|
546 | 473 |
|
547 | 474 | - [Rust docs](https://docs.rs/neutralts/latest/neutralts/)
|
548 | 475 | - [Template docs](https://franbarinstance.github.io/neutralts-docs/docs/neutralts/doc/)
|
549 | 476 | - [IPC server](https://github.com/FranBarInstance/neutral-ipc/releases)
|
550 |
| -- [IPC server and clients](https://github.com/FranBarInstance/neutral-ipc) |
| 477 | +- [IPC clients](https://github.com/FranBarInstance/neutral-ipc/tree/master/clients) |
551 | 478 | - [Repository](https://github.com/FranBarInstance/neutralts)
|
552 | 479 | - [Crate](https://crates.io/crates/neutralts)
|
553 | 480 | - [PYPI Package](https://pypi.org/project/neutraltemplate/)
|
554 |
| -- [Example Web App](https://gitlab.com/neutralfw/neutralts/-/tree/master/web-app) |
555 |
| -- [Examples](https://franbarinstance.github.io/neutralts-docs/) |
| 481 | +- [Examples](https://github.com/FranBarInstance/neutralts-docs/tree/master/examples) |
0 commit comments