https://github.com/aisk/naive
Naive is a too young too simple template engine
https://github.com/aisk/naive
Last synced: 8 months ago
JSON representation
Naive is a too young too simple template engine
- Host: GitHub
- URL: https://github.com/aisk/naive
- Owner: aisk
- Created: 2012-11-27T10:08:37.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-09-04T07:14:52.000Z (over 11 years ago)
- Last Synced: 2025-05-31T13:05:15.208Z (12 months ago)
- Language: Python
- Size: 145 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Naive Template Engine
## Introduce
Naive is a too young too simple template engine.Naive compile the template source file into Python VM bytecode **directly**.
## Grammar
Naive's grammer is mostly like Django's template engine.
``` python
from naive.compiler import Compiler
s = "Hello, My name is {{name}}, and I'm a {% if is_male %}boy{% else %}girl{% endif %} as you see."
co = Compiler(s).compile() # Actually co is a code object
eval(co, {'name': 'Asaka', 'is_male': True})
```