lektor-chameleon
lektor-chameleon is a plugin for the Lektor static site generator that makes is possible to write the templates using the Chameleon template engine.
To use the plugin, add it to your project:
$ lektor plugin add lektor-chameleon
Templates must have the .pt file extension.
Usage examples:
<html lang="${ this.alt }">
<h1 tal:content="this.title">Page title</h1>
<span tal:replace="bag('translate', this.alt, 'message')">message</span>
Filters
Lektor filters are available as functions:
For convenience, the following Jinja filters have also been made available as functions:
Usage examples:
<a href="${ url('/') }">Home page</a>
<a href="${ url('/', alt=this.alt) }">link text</a>
<link rel="stylesheet" href="${ asseturl('/static/custom.css') }"/>
<div tal:content="striptags(this.body)">Shortened body text</div>
<div tal:replace="indent(this.body.html, 2)">Page body</div>
<body>
${ structure:wordwrap(this.body.html, width=72) }
</body>
Extending templates
In order to have a base template that you want to extend for other templates, you have to use the macro and slot mechanism in Chameleon.
For example, a base template could look like this:
<html>
<head>
<!-- ... -->
</head>
<body>
<!-- ... -->
<div metal:define-slot="content">
Page content
</div>
<!-- ... -->
</body>
Assuming the base template is saved in a file called layout.pt,
a template that extends it would look like this:
<html tal:define="layout load:layout.pt" metal:use-macro="layout">
<div metal:fill-slot="content">
<p tal:replace="this.body">Page body</p>
</div>
</html>
Macros
Macros are written using Chameleon's METAL expressions. For example, the pagination macro template created by Lektor quickstart can be implemented as:
<div class="pagination" metal:define-macro="pagination">
<span tal:condition="not current.has_prev">« Previous</span>
<a tal:condition="current.has_prev" href="${ url(current.prev) }">« Previous</a>
| <span tal:replace="current.page">Current page</span> |
<span tal:condition="not current.has_next">Next »</span>
<a tal:condition="current.has_next" href="${ url(current.next) }">Next »</a>
</div>
Note that the macro requires a variable called current
which is assumed to hold the current page in the pagination.
The template that uses the macro has to define it
when calling the macro:
<html
tal:define="
layout load:layout.pt;
pagination load:macros/pagination.pt;
"
metal:use-macro="layout">
<div tal:define="current this.pagination"
metal:use-macro="pagination.macros.pagination">Pagination links</div>
</html>
Also note that the pagination macro template is loaded at the top html tag,
so that it can be used in the metal:use-macro clause.
Templating flow blocks
Flow block templates follow the same rules as Jinja flow block templates.
The this parameter refers to the block and the record parameter
refers to the object that contains the block.
Metadata
Release files for lektor-chameleon 0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lektor_chameleon-0.13.tar.gz | 6.9 kB | Without provenance | Details for lektor_chameleon-0.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lektor_chameleon-0.13-py3-none-any.whl | Python 3 | none | any | Details for lektor_chameleon-0.13-py3-none-any.whl |
Total release size: 12.4 kB
Release files / lektor_chameleon-0.13.tar.gz
| Download URL | lektor_chameleon-0.13.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75e4660f8ecaff2c4bc3fba1c23e22884b9494ef5048e7f51b74d8515751768d
|
|
BLAKE2b-256 checksum How to use checksums |
23382bdff02295eabc72311be641884fccde9d8c8235c93adbfc97b678a2482f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / lektor_chameleon-0.13-py3-none-any.whl
| Download URL | lektor_chameleon-0.13-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fafc808b9883bdab60117aa065e6b26364e71752746d48d8108f1e17b2b5001f
|
|
BLAKE2b-256 checksum How to use checksums |
3b5f280f72111097729957d3d22aac32f94093a676f83b2d1f089bfe384dd278
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for lektor-chameleon 0.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.