Skip to main content

A Lektor Plugin for Debugging Help

Project description

Lektor Debug

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

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-debug-0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

lektor_debug-0.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file lektor-debug-0.1.tar.gz.

File metadata

  • Download URL: lektor-debug-0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for lektor-debug-0.1.tar.gz
Algorithm Hash digest
SHA256 fac46e1be58f6ba5838a6580df1c52705c95dd84fff15fd85f8e1b0802d34620
MD5 630c13eab05ce35ef73b73868ae5ef72
BLAKE2b-256 a4b2ae42b439c41b632defa32ce1bed89900f67cda1229f812a62f306e5222e8

See more details on using hashes here.

File details

Details for the file lektor_debug-0.1-py3-none-any.whl.

File metadata

  • Download URL: lektor_debug-0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for lektor_debug-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ecaae8e2cebe161506077d03d20c0adc22cefa5ee5fdde11fcfedf9839ebe8af
MD5 63c6484652c20c8321f1b1d943902541
BLAKE2b-256 918ff84b1adddc5b349e1f51a54e8940bcf4408cf9b632a2cf701ece81056875

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page