format_html
Similar to str.format, but pass all arguments through conditional_escape(), and call mark_safe() on the result. This function should be used instead of str.format or % interpolation to build up small HTML fragments.
def format_html(
format_string: string,
*args: any,
**kwargs: any
) - > SafeString
Similar to str.format, but pass all arguments through conditional_escape(), and call mark_safe() on the result. This function should be used instead of str.format or % interpolation to build up small HTML fragments.
Parameters
| Name | Type | Description |
|---|---|---|
| format_string | string | The template string containing format placeholders to be populated. |
| *args | any | Variable positional arguments to be escaped and inserted into the format string. |
| **kwargs | any | Variable keyword arguments to be escaped and inserted into the format string. |
Returns
| Type | Description |
|---|---|
SafeString | The formatted HTML string with all arguments safely escaped and the final result marked as safe for rendering. |