mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-10 22:53:09 +00:00
79 lines
1.7 KiB
ReStructuredText
79 lines
1.7 KiB
ReStructuredText
Getting Started
|
|
================
|
|
|
|
Installation from `Pypi <https://pypi.org/project/djlint/>`__
|
|
--------------------------------------------------------------
|
|
|
|
.. code:: sh
|
|
|
|
pip install djlint
|
|
|
|
Linter Usage
|
|
------------
|
|
|
|
.. code:: sh
|
|
|
|
djlint src # file or path
|
|
|
|
# with custom extensions
|
|
djlint src -e html.dj
|
|
|
|
Formatter Usage
|
|
---------------
|
|
|
|
Foramtting is a beta tool. ``--check`` the output before applying changes.
|
|
|
|
Reformatting does not work with long json/html embedded into attribute data.
|
|
|
|
To check what may change in formatting run:
|
|
|
|
.. code:: sh
|
|
|
|
djlint . --check --ignore="H014,H017"
|
|
|
|
To format code run:
|
|
|
|
.. code:: sh
|
|
|
|
djlint . --reformat --indent=3
|
|
|
|
Ignoring Code
|
|
-------------
|
|
|
|
Code can be skipped by the linter and formatter by wrapping in djlint tags:
|
|
|
|
.. code:: html
|
|
|
|
{% djlint:off %}
|
|
<bad html to ignore>
|
|
{% djlint:on %}
|
|
|
|
Stdin vs Path
|
|
-------------
|
|
|
|
djLint also works with stdin.
|
|
|
|
.. code:: sh
|
|
|
|
echo "<div></div>" | djlint -
|
|
|
|
CLI Args
|
|
--------
|
|
|
|
.. code:: sh
|
|
|
|
Usage: python -m djlint [OPTIONS] SRC ...
|
|
|
|
djLint · lint and reformat HTML templates.
|
|
|
|
Options:
|
|
--version Show the version and exit.
|
|
-e, --extension TEXT File extension to check [default: html]
|
|
-i, --ignore TEXT Codes to ignore. ex: "H014,H017"
|
|
--reformat Reformat the file(s).
|
|
--check Check formatting on the file(s).
|
|
--indent INTEGER Indent spacing. [default: 4]
|
|
--quiet Do not print diff when reformatting.
|
|
--profile TEXT Enable defaults by template language. ops: django,
|
|
jinja, nunjucks, handlebars, golang
|
|
-h, --help Show this message and exit.
|