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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cuteninja-0.1.2.tar.gz.
File metadata
- Download URL: cuteninja-0.1.2.tar.gz
- Upload date:
- Size: 8.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d1e5917d6bba2c7d797c319757afd53209526c81897d3f014a75d2ece521318
|
|
| MD5 |
019b1d48f67795e2ca4313076a252d3d
|
|
| BLAKE2b-256 |
e2e103a3170113fab6cdace97933dc185d64bb614e1c5a7e0018676e2fdddbff
|
File details
Details for the file cuteninja-0.1.2-py3-none-any.whl.
File metadata
- Download URL: cuteninja-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f199486d1e48a15d84e707ebecc482670b838f480fcf8125f90b8f4407cdf282
|
|
| MD5 |
c0f157553f3d00a2a5ee8e58ec7b7eaa
|
|
| BLAKE2b-256 |
2e7480ce12bc4a792904038bb50b480c37bc4f9b184ea8459486224feca61679
|