A new backend templating system aims to solve the problem of template reuse across different programming languages by using an IPC-based approach similar to database connections.
I've been using my own PHP-based template system for years. A little over a year ago, I decided to port it to Rust and make it open source – that's how Neutral TS was born.
Web development today is heavily frontend-focused, with JavaScript templating everywhere. Neutral TS, on the other hand, is a backend templating system, so right off the bat that's its first weak spot. Still, there are cases where you genuinely need a backend template engine.
With that in mind, I thought: what if the main feature was being language-agnostic? The exact same templates could be reused in any programming language. Another feature – "objects" – lets you create a plugin that can be embedded in any Neutral TS template and work regardless of the host language. Right now objects are experimental and must be written in Python, but that's not a problem even if your main app is in Rust or PHP, for example.
So I can build a set of web templates and use them interchangeably from a Rust app, a Python app, a PHP app, or whatever.
Neutral TS works natively in Rust and Python. For other languages you need an IPC, and to illustrate that I like to use the MySQL (or any database) analogy. MySQL runs a TCP server to talk to your app: you send a query, you get a result. Neutral TS can also run as a TCP server – you send the template, you get the rendered result. The language doesn't matter, and just like with MySQL the result is always exactly the same.
This model is also more secure than the traditional one, because templates are rendered in a separate sandbox with no shared memory.
I tend to build complex things with no real utility – you guys can tell me if that's the case :-)
Rust crate: https://crates.io/crates/neutralts Python package: https://pypi.org/project/neutraltemplate/
To use it as an IPC you need a server and a client:
Server: https://github.com/FranBarInstance/neutral-ipc/releases Clients: https://github.com/FranBarInstance/neutral-ipc/tree/master/clients Examples: https://github.com/FranBarInstance/neutralts-docs/tree/master/examples

Comments
Please log in or register to join the discussion