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 using the >> operator:

<!-- 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.

Filename, size & hash SHA256 hash help File type Python version Upload date
lektor-chameleon-0.3.tar.gz (2.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page