parse_bits
Parse bits for template tag helpers simple_tag and inclusion_tag, in particular by detecting syntax errors and by extracting positional and keyword arguments.
def parse_bits(
parser: django.template.base.Parser,
bits: list of str,
params: list of str,
varargs: str or null,
varkw: str or null,
defaults: tuple or null,
kwonly: list of str,
kwonly_defaults: dict or null,
name: str
) - > tuple
Parse bits for template tag helpers simple_tag and inclusion_tag, in particular by detecting syntax errors and by extracting positional and keyword arguments.
Parameters
| Name | Type | Description |
|---|---|---|
| parser | django.template.base.Parser | The template parser instance used to compile filter expressions from the bits. |
| bits | list of str | The raw token segments extracted from the template tag to be parsed into arguments. |
| params | list of str | The list of expected positional parameter names defined in the helper function's signature. |
| varargs | str or null | The name of the variable positional arguments parameter (e.g., *args), or null if not supported. |
| varkw | str or null | The name of the variable keyword arguments parameter (e.g., **kwargs), or null if not supported. |
| defaults | tuple or null | A tuple of default values for positional parameters to determine which arguments are optional. |
| kwonly | list of str | The list of parameter names that must be provided as keyword-only arguments. |
| kwonly_defaults | dict or null | A mapping of keyword-only parameter names to their default values. |
| name | str | The name of the template tag being parsed, used for generating descriptive syntax error messages. |
Returns
| Type | Description |
|---|---|
tuple | A two-element tuple containing a list of compiled positional argument filters and a dictionary of keyword argument filters. |