Skip to main content

Lektor Expression Type Plugin

PyPI version PyPI Supported Python Versions GitHub license GitHub Actions (Tests)

Add jinja-evaluated types, expression and format_expression, to Lektor.

These allow one to define data model fields whose values are Jinja2 expressions.

The Types

Both the expression and format_expression types are evaluated by the jinja template engine.

expression

The expression type is evaluated as a Jinja2 expression.

An example value for this type might be:

this.children.order_by('-pub_date').limit(4)

This would evaluate to a Lektor Query instance.

format_expression

The format_expression type is evaluated as a Jinja2 template. It will always evaluate to a string.

An example value for this type might be:

The blog contains {{ site.get('/blog').count() }} pages.

Installation

Add lektor-expression-type to your project from command line:

lektor plugins add lektor-expression-type

See the Lektor plugin documentation for more information.

Motivating Example

Suppose you want to create an Index data model, for pages which will be used display lists of other pages on your site. You could create a model definition like this (called, perhaps, models/index.ini):

[model]
name = Index Page
label = Index: {{ this.title}}

[fields.title]
label = Title
type = string

[fields.items]
label = Items
type = expression
description = Pages to list on this page

In a particular index page which uses this model, you might set the items field to site.get('/projects').filter(F.tag == 'interesting'), then in the page template (e.g. in templates/index.html) one could reference the items field (e.g. {% for page in this.items %}) to determine which pages to display on the page.

Author

Jeff Dairiki dairiki@dairiki.org

Changelog

0.1 — 2021-02-05

No code changes.

Update development status classifier to "stable".

Fixes

  • Include the correct LICENSE file.

0.1b1 — 2020-05-05

Initial release.

Metadata

Release files for lektor-expression-type 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lektor-expression-type 0.1
File Size Uploaded
lektor-expression-type-0.1.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lektor-expression-type 0.1
File Interpreter ABI Platform
lektor_expression_type-0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 12.6 kB

Release files / lektor-expression-type-0.1.tar.gz

Download URL lektor-expression-type-0.1.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7022ce953ca23b09d168b1694fa00bc8ef3b00e131cacad11fe5046ae033c729
BLAKE2b-256 checksum
How to use checksums
0e95b48a06f084967f220e0befa6048f18606b53edb7a69504a9c25502c86f8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0+

Release files / lektor_expression_type-0.1-py2.py3-none-any.whl

Download URL lektor_expression_type-0.1-py2.py3-none-any.whl
Size 4.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e75316feaed2927de2367521094cb3f35cff4957560e7a96be10d08a3c5950f5
BLAKE2b-256 checksum
How to use checksums
7999a58e71ee23a9172af4dbd3e87c7738cd4e91501a1f1627720987b64cc0cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0+

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page