Skip to main content

HTML to Django Converter

Project description

HTML To Django

tests workflow stylecheck workflow

Converts HTML files with special attributes to Django templates.

Installation

pip install html-to-django

Usage

html_to_django [-h] [-r] path

path can either be a path to a file or a folder. When a file is passed only the file itself will be converted. When a folder is passed, all files ending in .html will be replaced. This searches through the folder recursivley.

Use -r to replace the original files, instead of creating new ones. By default, new ones are created in place next to the existing files, with the extension .n.html.

You can also use the html_to_django_r command if you are unable to pass the -r parameter (e.g. with the Bootstrap Studio "Export Script" setting).

Attributes

To add Django template tags to your HTML files, you need to add special attributes to your HTML tags like this:

<div dj-for="user in users">
    <p>{{ user.name }}</p>
</div>

This will be converted to:

{% for user in users %}
<p>{{ user.name }}</p>
{% endfor %}

A complete list of supported attributes can be found here.

Contributing

To learn how to contribute to this project, please see CONTRIBUTING.md.

Project details


Download files

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

Source Distribution

html_to_django-0.0.2.tar.gz (20.1 kB view hashes)

Uploaded Source

Built Distribution

html_to_django-0.0.2-py3-none-any.whl (18.2 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