Meet new Sparrow plugin jinjalint to lint jinja templates.
Let's get started!
Setup a tom task
$ tom --edit jinja-lint
task-run "lint my code", "jinjalint", %( args => [ "templates/", ["verbose"] ] );
Put some templates to check into templates/
directories
$ mkdir templates/
Run check
$ tom jinja-lint 21:03:50 10/17/2020 [repository] index updated from file:///home/ubuntu/repo/api/v1/index 21:03:51 10/17/2020 [lint my code] run [jinjalint templates/ --verbose] ... 21:03:51 10/17/2020 [lint my code] Files being analyzed: 21:03:51 10/17/2020 [lint my code] templates/template.html 21:03:51 10/17/2020 [lint my code] 21:03:51 10/17/2020 [lint my code] templates/template.html:3:5: Parse error: expected one of '[:a-z]', 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'script', 'source', 'style', 'track', 'wbr', '{#', '{%', '{{' at 2:5 21:03:51 10/17/2020 [lint my code] task exit status: 1 21:03:51 10/17/2020 [lint my code] task lint my code FAILED
That is it! You no longer miss errors in your jinja templates.
Check updates on SparrowHub.io - universal automation repository.
Aleksei
Top comments (1)
Bookmarked. Will look at adding this as a check for my Ansible CI pipeline