Conversation
Co-authored-by: me <me@rasulkireev.com>
There was a problem hiding this comment.
Greptile Summary
This PR fixes a Django TemplateSyntaxError that was occurring when rendering article cards in the Ask HN Digests application. The error was caused by the article_card.html template attempting to use a custom split filter without having the necessary templatetags loaded.
The changes involve two components:
- Template Fix: Added
{% load markdown_extras %}directive to the top ofarticle_card.htmlto make custom template filters available - Filter Implementation: Added the missing
splitfilter to thecore/templatetags/markdown_extras.pymodule
The split filter is used in the template to process article tags stored as comma-separated strings (e.g., "python,django,web") and convert them into individual tag elements for display. The filter takes a delimiter parameter (defaulting to comma) and returns a cleaned list of non-empty, stripped strings.
This fix integrates well with Django's template system architecture, where custom filters must be explicitly defined in templatetags modules and loaded in templates before use. The markdown_extras module already existed and contained other custom filters like the markdown filter, making it the logical place for this string manipulation utility. The change also includes minor formatting cleanup in the existing markdown filter by removing unnecessary blank lines.
Confidence score: 5/5
- This is a straightforward template syntax fix that directly addresses a runtime error with no risk of side effects
- The implementation follows Django best practices for custom template filters with proper error handling and string filtering
- Files are low-risk template and utility code with clear, isolated functionality
2 files reviewed, no comments
Fix
TemplateSyntaxError: Invalid filter: 'split'by explicitly loadingmarkdown_extrastemplatetags inarticle_card.htmland cleaning upmarkdownfilter formatting.Slack Thread
Learn more about Cursor Agents