Skip to main content

KDL as HTML replacement for Jinja2 templates

Project description

cuteninja

A python package that allows you to use KDL as the markup with Jinja2 syntax support.

Why? Because KDL is much more readable than HTML. While looking through the KDL repository I found a example file that used KDL as an alternative of HTML. That was what give me the initial idea of using KDL as the markup with Jinja in Python for succint and maintainable template.

This packages doesn't do much, it extract the Jinja syntax from source files and then parses the KDL via kdl-rs which generates the HTML. The previously extracted Jinja syntax is restored and returned as valid HTML with Jinja syntax. i.e.

!DOCTYPE html
html lang=en {
    head {
        title "{{ page_title }}"
    }
    body {
        h1 "Hello, {{ user.name }}!"
        {% if user.is_authenticated %}
        div class=content {
            p "You are logged in."
        }
        {% else %}
        div class=login {
            a href="/login" "Please log in"
        }
        {% endif %}
    }
}

is turned to the following:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>{{ page_title }}</title>
    </head>
    <body>
        <h1>Hello, {{ user.name }}!</h1>
        {% if user.is_authenticated %}
        <div class="content">
            <p>You are logged in.</p>
        </div>
        {% else %}
        <div class="login">
            <a href="/login">Please log in</a>
        </div>
        {% endif %}
    </body>
</html>

Contributing

This is an early-stage project with lots of room for improvement. You are welcome to help out in any shape or form.

License

MIT

Credits

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

cuteninja-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

cuteninja-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file cuteninja-0.1.0.tar.gz.

File metadata

  • Download URL: cuteninja-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"26.05","id":"yarara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cuteninja-0.1.0.tar.gz
Algorithm Hash digest
SHA256 18b51104f2b4ad48c1335490f0ee4721860668192917fed67c974fb14820140a
MD5 be71a9b131d208fb7b0c378f53e3eca9
BLAKE2b-256 db0db2ad5ed7458e4547bbb9ba902ec822851c6915f7f73fdca5edff8374e941

See more details on using hashes here.

File details

Details for the file cuteninja-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cuteninja-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"26.05","id":"yarara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cuteninja-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1e035e4e0b1f99cd1057a3ffe24450bf7aa0e71276b41157511ea3655bc3148
MD5 63b6c80fb9c4eaefc2965f8dee1e4863
BLAKE2b-256 1b924d2e57b2afb1e6447978102f71cee062f4aa38d7671cd2c0ece96de56b61

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