Fox template language.
What makes Fox template language special.
The indentation based syntax allows you to easily read and write code while keeping the source code well formatted.
The full Python API out of the box:
span 'mario'.capitalize()
Like in Django you have a few keywords protectiong you from errors (e.g. csrf_token).
Start each line with an HTML tag, a Fox keyword or a string.
Fox keywords:
autoescape
;block
;comment
or#
;csrf_token
;cycle
;debug
;extend
;filter
;firstof
;include
;load
;lorem
;now
(fordatetime.datetime.now
);regroup
?spaceless
;- url;
- verbatim;
widthratio
.
Special keywords: - frag
or :
.
You can either use concatenation, string template or format.
The statement always start with an HTML tag, a Fox keyword or a Python comment (#) so the keyword del and the HTML tag del don't conflict:
- tag (e.g.
div
)- string (e.g.
"Hello, world!"
) - code (e.g.
f"Hello, {name}"
) - attribute (e.g.
src
)
- string (e.g.
- keyword (e.g.
frag
)- code
- comment (e.g.
# TODO: Foo.
)
DTL | Fox |
---|---|
|
span value or "nothing" |
{% load static %} <br> <img src="{% static "i/hi.jpg" %}" alt="!"> | load static img src=(static 'images/hi.jpg') alt='Hi!' |
<p> {% with total=business.employees.count %} <span>{{ total }} employee{{ total|pluralize }}</span> {% endwith %} </p> | frag total = business.employees.count # FIXME: Global scope. span f'{total} employee{total.pluralize()}' |
Django keywords (e.g. load, cycle, [static](https://docs.djangoproject.com/en/2.2/ref/templates/builtins/#std:templatetag-static), [url](https://docs.djangoproject.com/en/2.2/ref/templates/builtins/#url)) can't be methods! Django filter are used like methods.
The statement always start with an HTML tag, a Fox keyword or a Python comment (
#
) so the keyworddel
and the HTML tagdel
don't conflict.