Debugging Utilities

This section covers internal helpers and configuration data structures for visual swap debugging.

Debugging Reference (htmx_nav.debugging)

Debug-swap marker: Add an inline <script> to flash a target element when HTMX_NAV_DEBUG_SWAPS is enabled.

_build_marker_script is used both by Swap.render() internally and by the public debug_swap_marker templatetag.

htmx_nav.debugging.debug_swap_marker(target_id)[source]

Return an inline <script> tag to trigger a swap highlight animation.

Parameters:

target_id (str) – The DOM element ID to highlight.

Return type:

str

Returns:

An HTML script string if HTMX_NAV_DEBUG_SWAPS is enabled, otherwise an empty string.

Debugging Reference (htmx_nav.templatetags.htmx_nav)

Template tags for django-htmx-nav.

htmx_nav.templatetags.htmx_nav.htmx_nav_debug_marker(target_id)[source]

Render a debug-swap marker script for hand-crafted out-of-band fragments.

Emits the same inline <script> tag that Swap produces when target_id is configured and HTMX_NAV_DEBUG_SWAPS is enabled. Useful when writing manual OOB wrappers (e.g. within {% partialdef %} blocks) that bypass Swap auto-wrapping.

Parameters:

target_id (str) – Target DOM element ID to highlight.

Return type:

SafeString

Returns:

A safe HTML string containing the inline <script> tag when HTMX_NAV_DEBUG_SWAPS is enabled, or an empty string.

Example

{% load htmx_nav %}

<div id="breadcrumbs" hx-swap-oob="innerHTML">
    {% htmx_nav_debug_marker "breadcrumbs" %}
    <nav>...</nav>
</div>