Skip to main content

Lektor Debug

Example ran on the Lektor Example Project's /type page:

example.gif

This Plugin provides a {% debug %} template tag that will render helpful debugging information in a template. To use, simply add this tag in a template, and run lektor server in development mode with LEKTOR_DEV=1 lektor server.

This plugin replaces Lektor's built-in, optional {% debug %} tag from Jinja2's Debug Extension. That tag is completely superceded by this plugins, so we just replace it.

This plugins tag can also be left in with no ill-effects. Unless the environment variable LEKTOR_DEV=1 is set, {% debug %} will be a noop and return an empty string, unlike Lektor's current behavior which, since Jinja2's Debug Extension would not be added, would raise a TemplateSyntaxError.

{% debug %} contents

This tag automatically renders as a collapsed <detail> html element, so it is minimally invasive unless you need it. When expanded, it will show a Python-ish dict with keys for:

  • All fields available on this
  • The complete dir(this), which shows it's native attributes and methods (different from the above)
  • All flowblocks and their fields
  • All current template context, exactly like Jinja2's Debug Extension
  • All available template filters, exactly like Jinja2's Debug Extension
  • All available template tests, exactly like Jinja2's Debug Extension

The top-level keys are meant to quickly tell you what that piece of data is, but do not necessarily correspond to an available key in a real Python dict. For example, this.fields is not a key in any Lektor Python dict, but it's hopefully clear what this represents.

Flowblocks are listed as this.<flowblock name>.blocks, which is how you would access them in a template. Each flow field will present a list of dicts of all blocks' fields and their values.

This debug info is presented as a code block, ran through Lektor's markdown processor. Since that is the case, if you have Lektor Markdown Highlighter installed and configured, this will also use the syntax highlighting for Python.

Additional Template Context

This plugin also adds the following template variables globally:

  • {{ dir }} Python's dir builtin
  • {{ str }} Python's str builtin
  • {{ type }} Python's type builtin

Release files for lektor-debug 0.1.5

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-debug 0.1.5
File Size Uploaded
lektor-debug-0.1.5.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lektor-debug 0.1.5
File Interpreter ABI Platform
lektor_debug-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 9.0 kB

Release files / lektor-debug-0.1.5.tar.gz

Download URL lektor-debug-0.1.5.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b8082ceff3c7c9c950978744a6a763e3fa0756e3143f1cf94e063747a20bedaf
BLAKE2b-256 checksum
How to use checksums
41f46b49bf37ff62cb35dc1feb05c8f987314950d76f1a2f203cdeb72c0cf248
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / lektor_debug-0.1.5-py3-none-any.whl

Download URL lektor_debug-0.1.5-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
412c9a5dedd35a85a9af91697a22b773259b5ecd8e5d11a32ded7df7aa1cd6fc
BLAKE2b-256 checksum
How to use checksums
cff7fd0e8d7ab1dcf0ebdafa3e34c71bb8bde8c62eae897a5e12ea8ea712c022
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

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