Skip to content

Mako template linter and formatter

djLint lints and formats Mako templates. Set the mako profile so the rules and the formatting fit them.

What is Mako?

With the mako profile, a control line such as % if x: and a ## comment always keep a line of their own, and a tag whose attributes depend on control lines keeps them as written. Python blocks and the contents of <%doc> and <%text> are left alone, and so is a script or style that holds Mako syntax under --format-js or --format-css. The lines between % if and % endif, and between a <%block> or <%def> tag and its closing tag when each has a line of its own, are indented like any other block. The code in a ${} expression is left as written.

Terminal window
djlint /path/to/templates --profile=mako

Configure djLint in your project’s pyproject.toml, djlint.toml / .djlint.toml, or .djlintrc file.

pyproject.toml
[tool.djlint]
profile = "mako"
djlint.toml / .djlint.toml
profile = "mako"
.djlintrc
{ "profile": "mako" }