https://github.com/franbarinstance/neutraltemplate
Neutralts template engine for the Web, python package
https://github.com/franbarinstance/neutraltemplate
neutral python-rust python-template python-template-engine python-templating template-engine templating templating-engine templating-language
Last synced: 3 months ago
JSON representation
Neutralts template engine for the Web, python package
- Host: GitHub
- URL: https://github.com/franbarinstance/neutraltemplate
- Owner: FranBarInstance
- License: apache-2.0
- Created: 2025-04-24T20:12:32.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2025-09-09T11:07:51.000Z (4 months ago)
- Last Synced: 2025-09-09T14:15:44.039Z (4 months ago)
- Topics: neutral, python-rust, python-template, python-template-engine, python-templating, template-engine, templating, templating-engine, templating-language
- Language: Python
- Homepage: https://franbarinstance.github.io/neutralts-docs/docs/neutralts/doc/
- Size: 239 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Python package for Neutral TS
=============================
Neutral is a templating engine for the web written in Rust, designed to work with any programming language (language-agnostic) via IPC/Package and natively as library/crate in Rust.
Install Package
---------------
```
pip install neutraltemplate
```
Usage
-----
See: [examples](https://github.com/FranBarInstance/neutralts-docs/tree/master/examples/python)
```
from neutraltemplate import NeutralTemplate
schema = """
{
"config": {
"cache_prefix": "neutral-cache",
"cache_dir": "",
"cache_on_post": false,
"cache_on_get": true,
"cache_on_cookies": true,
"cache_disable": false,
"disable_js": false,
"filter_all": false
},
"inherit": {
"locale": {
"current": "en",
"trans": {
"en": {
"Hello nts": "Hello",
"ref:greeting-nts": "Hello"
},
"es": {
"Hello nts": "Hola",
"ref:greeting-nts": "Hola"
},
"el": {
"Hello nts": "Γεια σας",
"ref:greeting-nts": "Γεια σας"
}
}
}
},
"data": {
"CONTEXT": {
"ROUTE": "",
"HOST": "",
"GET": {},
"POST": {},
"HEADERS": {},
"FILES": {},
"COOKIES": {},
"SESSION": {},
"ENV": {}
},
"hello": "Hello",
"arr": {
"hello": "Hello"
}
}
}
"""
template = NeutralTemplate("file.ntpl", schema)
contents = template.render()
# e.g.: 200
status_code = template.get_status_code()
# e.g.: OK
status_text = template.get_status_text()
# empty if no error
status_param = template.get_status_param()
# act accordingly at this point according to your framework
```
Links
-----
Neutral TS template engine Python Package.
- [Template docs](https://franbarinstance.github.io/neutralts-docs/docs/neutralts/doc/)
- [Repository](https://github.com/FranBarInstance/neutraltemplate)
- [Crate](https://crates.io/crates/neutralts)
- [PYPI Package](https://pypi.org/project/neutraltemplate/)
- [Examples](https://github.com/FranBarInstance/neutralts-docs/tree/master/examples/python)