Skip to main content

Show a summary of a Django or Jinja template

Project description

summarize-template

PyPI Changelog Tests License

Show a summary of a Django or Jinja template

Installation

Install this tool using pip:

pip install summarize-template

Usage

You can run the command against a template file like this:

summarize-template path/to/template.html

The tool will output just the structural tags from the template.

Example

Given a template that looks like this:

{% extends "base.html" %}

{% block title %}This is the title{% endblock %}

{% block content %}
<h1>{{ title }}</h1>
{% if docs %}
    <ul>
        {% for doc in docs %}
            <li><a href="{{ doc.url }}">{{ doc.title }}</a></li>
        {% endfor %}
    </ul>
{% endif %}
{% endblock %}

Running summarize-template against it will produce the following:

{% extends "base.html" %}
{% block title %}   {% endblock %}
{% block content %}
{{ title }}
{% if docs %}
        {% for doc in docs %}
             {{ doc.url }}{{ doc.title }}
        {% endfor %}
{% endif %}
{% endblock %}

Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd summarize-template
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

summarize-template-0.1.tar.gz (6.6 kB view hashes)

Uploaded Source

Built Distribution

summarize_template-0.1-py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page