Skip to content

Instantly share code, notes, and snippets.

@ogonkov
Last active August 2, 2020 08:24
Show Gist options
  • Save ogonkov/fcbff2b84615b0207c8bdc2c2addff95 to your computer and use it in GitHub Desktop.
Save ogonkov/fcbff2b84615b0207c8bdc2c2addff95 to your computer and use it in GitHub Desktop.
Jinja2 vs Nunjucks features comparison
Jinja2 Nunjucks Support
Filters 50 40 80%
Fully compatible 50 27 54%
Jinja2 Nunjucks Compatible Comment
abs abs ✔️ abs/Math.abs alias
attr
batch batch ✔️ same implementation
capitalize capitalize ✔️
center center ✔️
default/d default/d ✔️
dictsort dictsort reverse kwarg missed
escape/e escape/e ✔️ markup.escape/own implementation
filesizeformat
first first ✔️ Jinja2 have async filter of same name ❗
float float ✔️
forceescape forceescape ✔️
format
groupby groupby ✔️ Jinja2 have async filter of same name ❗
indent indent blank kwarg missing
int int base kwarg missing
join join Nested attributes is not supported. Autoescape seems missing. Jinja2 have async filter of same name ❗
last last ✔️
length/count length count alias missing
list list ✔️ Jinja2 have async filter of same name ❗
lower lower ✔️
map
max
min
pprint pprint.pformat with default options
random random ✔️
reject reject ✔️ Jinja2 have async filter of same name ❗
rejectattr rejectattr Jinja2 allows dotted arg and test name with args as the rest arguments. Jinja2 have async filter of same name ❗
replace replace ✔️ autoescape seems not respected ❗
reverse reverse ✔️
round round ✔️ Jinja2 throws exception when method is not one of the known
safe safe ✔️
select select ✔️ Jinja2 have async filter of same name ❗
selectattr selectattr Jinja2 allows dotted arg and test name with args as the rest arguments. Jinja2 have async filter of same name ❗
slice slice ✔️ Jinja2 have async filter of same name ❗
sort sort Nested attributes support missing
string string ✔️ markupsafe.soft_str
striptags striptags ✔️ Nunjucks have additional argument to preserve line breaks
sum sum Nested attributes support missing. Jinja2 have async filter of same name ❗
title title Jinja2 split string by more symbols than a single space
tojson dump ✔️
trim trim chars kwarg missing
truncate truncate leeway kwarg missing
unique
upper upper ✔️
urlencode urlencode ✔️
urlize urlize target and rel kwargs missing
wordcount wordcount ✔️ Jinja2 seems always return numbers ❗
wordwrap
xmlattr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment