InclusionNode
This class represents a template node that renders a specific template with a context provided by a helper function. It handles the resolution of arguments, manages template loading and caching within the render context, and ensures that essential data like CSRF tokens are propagated to the sub-template.
Attributes
| Attribute | Type | Description |
|---|---|---|
| filename | string, [Template](../base/template.md?sid=django_template_base_template), or Iterable | The template name, template object, or list of template names used to render the inclusion tag's output. |
Constructor
Signature
def InclusionNode(
func: callable,
takes_context: boolean,
args: list,
kwargs: dict,
filename: str|Template|Iterable
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| func | callable | The function to be called by the inclusion tag. |
| takes_context | boolean | Flag indicating if the function accepts the template context as its first argument. |
| args | list | A list of positional arguments for the function. |
| kwargs | dict | A dictionary of keyword arguments for the function. |
| filename | `str | Template |
Methods
render()
@classmethod
def render(
context: django.template.Context
) - > string
Render the specified template and context. Cache the template object in render_context to avoid reparsing and loading when used in a for loop.
Parameters
| Name | Type | Description |
|---|---|---|
| context | django.template.Context | The current template rendering context used to resolve arguments and manage the render cache |
Returns
| Type | Description |
|---|---|
string | The rendered HTML content of the inclusion template as a string |