Fix template_filter decorator to support both usage styles and update docstring; update CHANGES.rst

This commit is contained in:
Akshay 2025-05-16 14:49:45 +05:30
parent c94824744c
commit 6ff24afee8
3 changed files with 42 additions and 23 deletions

View file

@ -0,0 +1,24 @@
import pytest
from flask import Flask, render_template_string
def test_template_filter_without_parentheses():
app = Flask(__name__)
@app.template_filter
def double(x):
return x * 2
with app.app_context():
output = render_template_string("{{ 2 | double }}")
assert output == "4"
def test_template_filter_with_parentheses():
app = Flask(__name__)
@app.template_filter()
def triple(x):
return x * 3
with app.app_context():
output = render_template_string("{{ 3 | triple }}")
assert output == "9"