From 894b17ba24cb3781d5b3d65a1767fec5e6f7581c Mon Sep 17 00:00:00 2001 From: Christopher Pickering Date: Tue, 30 Nov 2021 11:07:39 +0100 Subject: [PATCH] updated docs --- docs/djlint/best_practices.rst | 2 +- docs/djlint/integrations.rst | 75 ++++++++++++++++++++++++++++++++++ docs/index.rst | 1 + 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 docs/djlint/integrations.rst diff --git a/docs/djlint/best_practices.rst b/docs/djlint/best_practices.rst index 46b91b8..06b0e20 100644 --- a/docs/djlint/best_practices.rst +++ b/docs/djlint/best_practices.rst @@ -23,7 +23,7 @@ This pattern is not recommended: ``format_attribute_template_tags`` and Spaceless Conditional Attributes ----------------------------------------------------------------------- -If ``format_attribute_template_tags`` option is enabled, conditional attributes should use spaceless tags, for example ``{% if a -%}`` in nunjuck and jinja, or ``{% spaceless %}{% if a %}{% endspaceless %}`` in django, to remove spaces inside the. +If ``format_attribute_template_tags`` option is enabled, conditional attributes should use spaceless tags, for example ``{% if a -%}`` in nunjuck and jinja, to remove spaces inside the. djLint will format long attributes onto multiple lines, and the whitespace saved inside of attributes could break your code. diff --git a/docs/djlint/integrations.rst b/docs/djlint/integrations.rst new file mode 100644 index 0000000..4fa30a4 --- /dev/null +++ b/docs/djlint/integrations.rst @@ -0,0 +1,75 @@ +Integrations +============ + +There are several editor integrations build for djLint. + +Pre-Commit +---------- + +djLint can be used as a `pre-commit `_ hook. + +The repo provides multiple pre-configured hooks for specific djLint profiles (it just pre-sets the ``--profile`` argument and tells pre-commit which file extensions to look for): + +* ``djlint-django`` for Django templates: + +This will look for files matching ``templates/**.html`` and set ``--profile=django``. + +* ``djlint-jinja`` + +This will look for files matching ``*.j2`` and set ``--profile=jinja``. + +* ``djlint-nunjucks`` + +This will look for files matching ``*.njk`` and set ``--profile=nunjucks``. + +* ``djlint-handlebars`` + +This will look for files matching ``*.hbs`` and set ``--profile=handlebars``. + +* ``djlint-golang`` + +This will look for files matching ``*.tmpl`` and set ``--profile=golang``. + +Note that these predefined hooks are sometimes too conservative in the inputs they accept (your templates may be using a different extension) so pre-commit explicitly allows you to override any of these pre-defined options. See the `pre-commit docs `_ for additional configuration + +Default Django example +^^^^^^^^^^^^^^^^^^^^^^ + +.. code:: yaml + + repos: + - repo: https://github.com/Riverside-Healthcare/djLint + rev: 0.5.10 # grab latest tag from GitHub + hooks: + - id: djlint-django + + +Handlebars with .html extension instead of .hbs +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. code:: yaml + + repos: + - repo: https://github.com/Riverside-Healthcare/djLint + rev: 0.5.10 # grab latest tag from GitHub + hooks: + - id: djlint-handlebars + files: "\\.html" + +You can use the ``files`` or ``exclude`` parameters to constrain each hook to its own directory, allowing you to support multiple template languages within the same repo. + +SublimeText Linter +------------------ + +djLint can be used as a SublimeText Linter plugin. It can be installed via `package-control `_. + +1. ``cmd + shft + p`` +2. Install SublimeLinter +3. Install SublimeLinter-contrib-djlint + +Ensure djLint is installed in your global python, or on yout ``PATH``. + +coc.nvim +-------- + +https://www.npmjs.com/package/coc-htmldjango diff --git a/docs/index.rst b/docs/index.rst index 609e906..ffc0e6f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,6 +15,7 @@ HTML Template Linter and Formatter djlint/rules djlint/formatter djlint/configuration + djlint/integrations djlint/best_practices djlint/changelog