Skip to content

Commit

Permalink
Merge pull request #1495 from Flimm/document_validate_templates
Browse files Browse the repository at this point in the history
Improve documentation of validate_templates
  • Loading branch information
trbs committed Mar 6, 2020
2 parents c65a155 + d3c9d3c commit 1dd38e8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/command_extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Current Command Extensions

* *update_permissions* - Reloads permissions for specified apps, or all apps if no args are specified.

* *validate_templates* - Validate templates on syntax and compile errors.
* :doc:`validate_templates` - Validate templates on syntax and compile errors.

* *set_default_site* - Set parameters of the default `django.contrib.sites` Site using `name` and `domain` or `system-fqdn`.

Expand Down
27 changes: 26 additions & 1 deletion docs/validate_templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ validate_templates

:synopsis: Checks templates on syntax or compile errors.

This will catch any invalid Django template syntax, for example::

{% foobar %}

{% comment %}
This throws this error:
TemplateSyntaxError Invalid block tag on line 1: 'foobar'. Did you forget to register or load this tag?
{% endcomment %}

Note that this will not catch invalid HTML, only errors in the Django template
syntax used.

Options
-------

Expand Down Expand Up @@ -56,4 +68,17 @@ check those as well.
Usage Example
-------------

./manage.py validate_templates
::

./manage.py validate_templates


You can also integrate it with your tests, like this::

import unittest
from django.core.management import call_command

class MyTests(unittest.TestCase):
def test_validate_templates(self):
call_command("validate_templates")
# This throws an error if it fails to validate

0 comments on commit 1dd38e8

Please sign in to comment.