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.1.tar.gz (7.3 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.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cuteninja-0.1.1.tar.gz
  • Upload date:
  • Size: 7.3 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.1.tar.gz
Algorithm Hash digest
SHA256 ed6275cd3b423be5b3f3586955c8deab8c354294fbf384058b61121e8511723b
MD5 049905d3d90e4d792b4e4f0a5a979d6e
BLAKE2b-256 937de138587e9541e55ecffa62f8e9a1b1ce30e141ca634d6155d99b6c27bcee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cuteninja-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b5e0e12796d8f4ad74fedb8647a85102d86d09949374a98e791f67223d2ee7bc
MD5 373773941f70f68c1717752993a67086
BLAKE2b-256 80cce777e5e66f68c7c7021773db34d92a39dd13174d88756204281f48e11d43

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