Giter VIP home page Giter VIP logo

django-templates-forest's Introduction

Django Templates Forest (BETA)

Templates Forest is just a series of django commands that might help you visualize your templates' inheritance and will give you some detailed information about them so you could clean your template's structure

Install

  1. Add templates-forest to your requirements (and install it, via pip or something)
  2. Add templates_forest to your INSTALLED_APPS
  3. Add APPLICATION_DIR to your settings. This is the path to your app

How to use

There are currently three django commands and they all have the same common parameters.

Common parameters

  • --quiet Will ignore the warnings and problems found when parsing the templates

  • --include-packages If added, it will not only parse the templates on APPLICATION_DIR but also the installed packages (INSTALLED_APPS)

  • --vars You can pass some variables that will be used in the template's context, for example when you use dynamic inheritance e.g.: {% extends my_var %} you can call the command using: --vars my_var=foo.html.

    For boolean variables you can pass True or False values, for example --vars my_var=False

    It also works if the variable in the template is an attribute of an object: --vars foo.bar.aze=base.html

templates_trees

Displays a list of trees found. For each tree we display the top template to select which tree to display.

Next to each tree root we have the height of the three (the number of edges on the longest downward path between the root and a leaf)

Templates_trees command example

template_info <template path>

Displays the information for a single template: His position inside a tree, all the templates included inside this template, and the list of templates that include this template:

template_info command example

templates_check

Using the template trees it will display a list of templates that we only included once ("useless include") and the orphan templates that were never included and that can't be found on the python files in APPLICATION_DIR

templates_check command example

django-templates-forest's People

Contributors

pleasedontbelong avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-templates-forest's Issues

"templates_check" wrong count on "templates included only once"

when launching templates_check a template is marked as "Templates included only once" even if it has been included more than once in a single template

To reproduce:when launching templates_check a template is marked as "Templates included only once" even if it has been included more than once in a single template

To reproduce:

  • in template parent.html
 {% include foo.html %}
 {% include foo.html %}
 {% include foo.html %}
...
  • launch templates_check
  • foo.html will be displayed in the "Templates included only once" section

Expected behavior

foo.html should not be in the "Templates included only once" section because it has been included multiple times

in template parent.html
{% include foo.html %}
{% include foo.html %}
{% include foo.html %}
...
launch templates_check
foo.html will be displayed in the "Templates included only once" section
Expected behavior

foo.html should not be in the "Templates included only once" section because it has been included multiple times

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.