Skip to content

Fix invalid split filter error#16

Open
rasulkireev wants to merge 1 commit intomainfrom
cursor/fix-invalid-split-filter-error-8340
Open

Fix invalid split filter error#16
rasulkireev wants to merge 1 commit intomainfrom
cursor/fix-invalid-split-filter-error-8340

Conversation

@rasulkireev
Copy link
Owner

Fix TemplateSyntaxError: Invalid filter: 'split' by explicitly loading markdown_extras templatetags in article_card.html and cleaning up markdown filter formatting.


Slack Thread

Open in Cursor Open in Web

Learn more about Cursor Agents

Co-authored-by: me <me@rasulkireev.com>
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Template Fix: Added {% load markdown_extras %} directive to the top of article_card.html to make custom template filters available
  2. Filter Implementation: Added the missing split filter to the core/templatetags/markdown_extras.py module

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

Edit Code Review Bot Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants