Skip to main content

Chameleon support for templating in Lektor.

Project description

This plugin makes it possible to write Lektor templates using Chameleon. It achieves this by replacing the Jinja renderer with the Chameleon renderer during template rendering.

The names defined in the Jinja environment are available in Chameleon templates:

<!-- Jinja -->
<h1>{{ this.title }}</h1>

<!-- Chameleon -->
<h1>${ this.title }</h1>

<!-- or -->
<h1 tal:content="this.title">Page title</h1>

<!-- Jinja -->
{{ bag('translate', this.alt, 'message') }}

<!-- Chameleon -->
<span tal:replace="bag('translate', this.alt, 'message')">message</span>

Many Lektor and Jinja filters are also available:

<!-- Jinja -->
<link rel="stylesheet" href="{{ '/static/custom.css'|url }}"/>

<!-- Chameleon -->
<link rel="stylesheet" href="${ '/static/custom.css'|url }"/>

Filters also accept parameters:

<!-- Jinja -->
<a href="{{ '.'|url(alt=this.alt) }}">link text</a>

<!-- Chameleon -->
<a href="${ '.'|url(alt=this.alt) }">link text</a>

But filter parameters must be given as keyword parameters:

<!-- incorrect -->
<div tal:replace="this.body|indent(4)">Page body</div>

<!-- correct -->
<div tal:replace="this.body|indent(width=4)">Page body</div>

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

lektor-chameleon-0.2.tar.gz (2.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page