Skip to main content

A Python script that converts HTML Files / Templates to Django compatible HTML Templates.

Project description

Djangify

A Python script that converts HTML Files / Templates to Django compatible HTML Templates.

Usage Info

username@hostname $ ./djangify.py -h
usage: djangify.py [-h] [-d [BASE_DIRECTORY]] [-a [APP_NAME]] [f [f ...]]

Converts specified html files or all html files to django format within a
specified directory.

positional arguments:
  f                    provide file names to convert

optional arguments:
  -h, --help           show this help message and exit
  -d [BASE_DIRECTORY]  Provide base directory
  -a [APP_NAME]        provide django app name

Description

Converts all the HTML files specified in the files (' f ') argument into Django templates, replacing the contents of 'src', 'href' and 'url' tags with their Django compatible static conterparts with their Django App name prefixed.

For Example:

To process a set of HTML files, copy the djangify.py script to the directory containing these HTML files, and run the following command, (Here 'blog' refers to the App name for which we are processing these files)

$ ./djangify.py -a blog

This command will replace all local files referenced in 'src', 'href' and 'url' tags in the following way :

Original :

    <img class="mySlides" src="res/landreg/1.jpg" style="width:100%">
    <li><a href="register.html">Register</a></li>

After script execution :

   <img class="mySlides" src=" {% static 'blog/res/landreg/1.jpg' %} " style="width:100%">
   <li><a href=" {% static 'blog/register.html' %} ">Register</a></li>

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

djangify-1.0.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

djangify-1.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file djangify-1.0.0.tar.gz.

File metadata

  • Download URL: djangify-1.0.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for djangify-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3bad342abe75fbcab2ad332cbfc16de8baecb2e28f59223e4ffaed9a877d41b0
MD5 5fd8ea108f00ea7976bcb66256a26e95
BLAKE2b-256 0d1d85dada639dc42f128efac992e49ca9182015164ad9a96b16ec500b33d762

See more details on using hashes here.

File details

Details for the file djangify-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: djangify-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for djangify-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25f8d17c07f044c44588c2fc374eff0985c0dac027abf546856c4997f25ef750
MD5 7db0ea4a4e97d561ff4f360c7d37123c
BLAKE2b-256 4368bace5b684e5ae79eea98142c8f3352ebef3d4ac778e858da156802074b62

See more details on using hashes here.

Supported by

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