{# Page assets live INSIDE the content block (the dj-root): dj-navigate swaps only that region, so anything in extra_head/extra_scripts is missing when a visitor arrives by live navigation. Behaviour lives in static/js/site-pages.js. #}
DJE-010 Error Template
Textarea newlines stripped by whitespace minifier
Error message
Textarea content loses newlines and formatting after renderThe _strip_comments_and_whitespace() function in mixins/template.py used re.sub(r'\s+', ' ') which collapsed all whitespace including newlines inside <textarea> elements. This caused multi-line textarea content to appear as a single line after server-side rendering. Fixed in v0.3.0 by adding <textarea> to the preserved blocks alongside <pre> and <code>.
bug-fixed template textarea whitespace
Affected versions: <0.3.0
Solution
Recommended
Upgrade to djust >= 0.3.0
This bug is fixed in djust 0.3.0. The whitespace minifier now preserves content inside <textarea>, <pre>, and <code> blocks.
Before (problematic)
# In mixins/template.py (old behavior)
def _strip_comments_and_whitespace(html):
# This collapsed ALL whitespace, including in textareas
html = re.sub(r"\s+", " ", html)
return html
After (fixed)
# In mixins/template.py (fixed)
def _strip_comments_and_whitespace(html):
# Preserve content in <pre>, <code>, and <textarea> blocks
preserved = {}
for tag in ("pre", "code", "textarea"):
pattern = re.compile(
rf"(<{tag}[^>]*>)(.*?)(</{tag}>)",
re.DOTALL
)
# ... preserve and restore blocks