fix: add nl2br filter and fix TemplateResponse arguments
- Add nl2br Jinja2 filter to convert newlines to <br> tags - Fix TemplateResponse argument order (request first) in error handlers - Fix type annotations for mypy - All 97 tests passing
This commit is contained in:
@@ -28,6 +28,21 @@ router = APIRouter(prefix="/web", tags=["web"])
|
||||
templates = Jinja2Templates(directory="app/presentation/templates")
|
||||
|
||||
|
||||
def nl2br(value: str) -> str:
|
||||
"""Convert newlines to HTML line breaks.
|
||||
|
||||
Args:
|
||||
value: String with newlines.
|
||||
|
||||
Returns:
|
||||
String with <br> tags instead of newlines.
|
||||
"""
|
||||
return value.replace("\n", "<br>\n")
|
||||
|
||||
|
||||
templates.env.filters["nl2br"] = nl2br
|
||||
|
||||
|
||||
class MockPost:
|
||||
"""Mock post object for UI demonstration.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user