Given the Flask template code below, what will be rendered?
{{ 'hello world'|capitalize }}The capitalize filter makes only the first letter uppercase and the rest lowercase.
The capitalize filter converts the first character to uppercase and the rest to lowercase. So 'hello world' becomes 'Hello world'.
Assuming a custom filter named reverse_string is registered in Flask, which template syntax correctly applies it to variable name?
Filters in Flask templates use the pipe | symbol.
Custom filters are applied using the pipe syntax like built-in filters. Calling as a function or tag is invalid.
Consider this Flask template snippet:
{{ 123|lower }}What error or output will this produce?
The lower filter expects a string input.
The lower filter calls the string method lower(). Since 123 is an integer, it raises an AttributeError.
Given this template code:
{{ ' Flask Framework ' | trim | upper }}What will be the rendered output?
Filters are applied left to right. trim removes spaces, upper makes uppercase.
First, trim removes spaces around the string, then upper converts all letters to uppercase.
Choose the correct statement about Flask template filters.
Think about how Flask connects custom filters to templates.
Custom filters must be registered with the Flask app to be available in templates. Filters do not modify Python variables directly and cannot execute arbitrary code.