A Django template engine to render untrusted template code
Project description
Django Safe Template Engine
Django template engine to render untrusted template code
Requirements
- Python 3.8 to 3.11
- Django 3.0
Available tools
Template engine:
from django.template import Template
from django_safe_template_engine.engine import SafeTemplateEngine
safe_engine = SafeTemplateEngine()
Template(source, engine=safe_engine)
Validator:
from django_safe_template_engine.validators import validate_safe_engine_template_syntax
template_code = '{% include "hacked.html" %}'
validate_safe_engine_template_syntax(template_code)
Trusted built-ins
The following tags and filters are allowed by this template engine.
Trusted tags
autoescape
comment
cycle
filter
firstof
for
for … empty
if
ifchanged
lorem
now
regroup
resetcycle
spaceless
templatetag
url
verbatim
widthratio
with
Trusted filters
addslashes
capfirst
escapejs
json_script
floatformat
iriencode
linenumbers
lower
make_list
slugify
stringformat
title
truncatechars
truncatechars_html
truncatewords
truncatewords_html
upper
urlencode
urlize
urlizetrunc
wordcount
wordwrap
ljust
rjust
center
cut
escape
force_escape
linebreaks
linebreaksbr
safe
safeseq
striptags
dictsort
dictsortreversed
first
join
last
length
length_is
random
slice
unordered_list
add
get_digit
date
time
timesince
timeuntil
default
default_if_none
divisibleby
yesno
filesizeformat
pluralize
phone2numeric
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 django_safe_template_engine-1.0.0.tar.gz
.
File metadata
- Download URL: django_safe_template_engine-1.0.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8475ea2c5388458106e32a8891e82964038191309dfa3cfddecfe1b38556be5 |
|
MD5 | 115a209fefca47ab95f88d2fd45813ab |
|
BLAKE2b-256 | 4bc2156c984f0da76aea967bc49ba81fe8b62464fd14eea9e454addf8ae74b6b |
File details
Details for the file django_safe_template_engine-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: django_safe_template_engine-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97c4d20216847ebe3cb51e1e78883a2fd5c4beead95bd35b98e1115370094aba |
|
MD5 | ec801501b991a30eaeaccb203b6d4b55 |
|
BLAKE2b-256 | dcf75a8b9cbbe72fb0f45c379f0b2c0b516a895d97c934f93c4f786b68526be4 |