Template Engine for HTML
Project description
Fox Template Engine Manual
Install
- Open your project in terminal
- activate virtual env
- Input 'pip install foxTemplateEngine'
How to use?
from foxTemplateEngine.template_engine import FoxEngine # transform() is a func for render your template to vanilla HTML
obj = FoxEngine('path', {}) # 'path' - path to template, {} - context
obj.getRenderedTemplateAsText() # getting a rendered template
obj.writeToFile('new_path') # saving to file by path: new_path
Example
Before (project/test.fox)
/body
% repeat 4 %
/h1
{{ context['var'] }}
START LOOP
% repeat 2 %
LOOOOOOOP
% end %
END LOOP
./h1
% end %
./body
Start this code
from foxTemplateEngine.template_engine import transform
obj = FoxEngine('test.fox', {
'var': 'Hello, World!'
})
obj.getRenderedTemplateAsText()
obj.writeToFile('test.html')
"""
function getRenderedTemplateAsText() is called first and only then writeToFile()
"""
After (project/test.html)
<body>
<h1>
Hello, World!
START LOOP
LOOOOOOOP
LOOOOOOOP
END LOOP
</h1>
<h1>
Hello, World!
START LOOP
LOOOOOOOP
LOOOOOOOP
END LOOP
</h1>
<h1>
Hello, World!
START LOOP
LOOOOOOOP
LOOOOOOOP
END LOOP
</h1>
<h1>
Hello, World!
START LOOP
LOOOOOOOP
LOOOOOOOP
END LOOP
</h1>
</body>
See tests for a better understanding of how the package works!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file foxTemplateEngine-2.1.1.tar.gz
.
File metadata
- Download URL: foxTemplateEngine-2.1.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61f2667e6fdfd75e919885bacabe9ef819ab82009f69d4652b6f1ef35905558e |
|
MD5 | a43b137fd62bb110224038c56ca2a98c |
|
BLAKE2b-256 | 6104c4f71095da38ce069d85e0b7e1f56dc00e06b99390208d78224d3a09c600 |
File details
Details for the file foxTemplateEngine-2.1.1-py3-none-any.whl
.
File metadata
- Download URL: foxTemplateEngine-2.1.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ea08e488968f856794af1b353835ca27d38c3259628a4046056940eeea6e043 |
|
MD5 | a3042a98a0481b2ab28678afcebd0daa |
|
BLAKE2b-256 | f676fe1494552c89a1fac4aaa14238824fa33684cdef0d5d750d979d09bd79e4 |