django_bird.templates¶
Module Contents¶
Classes¶
Functions¶
Generate a list of potential template names for a component. |
|
Find all component names used in a specific template. |
|
Data¶
API¶
- django_bird.templates.logger¶
‘getLogger(…)’
- django_bird.templates.get_template_names(name: str) list[str]¶
Generate a list of potential template names for a component.
The function searches for templates in the following order (from most specific to most general):
In a subdirectory named after the component, using the component name
In the same subdirectory, using a fallback ‘index.html’
In parent directory for nested components
In the base component directory, using the full component name
The order of names is important as it determines the template resolution priority. This order allows for both direct matches and hierarchical component structures, with more specific paths taking precedence over more general ones.
This order allows for:
Single file components
Multi-part components
Specific named files within component directories
Fallback default files for components
For example:
For an “input” component, the ordering would be:
{component_dir}/input/input.html{component_dir}/input/index.html{component_dir}/input.html
For an “input.label” component:
{component_dir}/input/label/label.html{component_dir}/input/label/index.html{component_dir}/input/label.html{component_dir}/input.label.html
Returns: list[str]: A list of potential template names in resolution order.
- django_bird.templates.get_default_engine_directories() list[pathlib.Path]¶
- django_bird.templates.get_app_template_directories() list[pathlib.Path]¶
- django_bird.templates.get_template_directories() collections.abc.Generator[pathlib.Path, Any, None]¶
- django_bird.templates.get_component_directory_names() list[pathlib.Path | str]¶
- django_bird.templates.get_component_directories(template_dirs: collections.abc.Iterator[pathlib.Path] | None = None) list[pathlib.Path]¶
- django_bird.templates.gather_bird_tag_template_usage() collections.abc.Generator[tuple[pathlib.Path, set[str]], Any, None]¶
- django_bird.templates._process_template_chunk(templates: list[tuple[pathlib.Path, pathlib.Path]]) list[tuple[pathlib.Path, set[str]]]¶
- django_bird.templates.find_components_in_template(template_path: str | pathlib.Path) set[str]¶
Find all component names used in a specific template.
Args: template_path: Path to the template file or template name
Returns: set[str]: Set of component names used in the template
- django_bird.templates.NodeVisitorMethod¶
None
- django_bird.templates.has_nodelist(node: django.template.base.Template | django.template.base.Node) TypeGuard[django.template.base.Template]¶
- class django_bird.templates.NodeVisitor(engine: django.template.engine.Engine)¶
Initialization
- visit(node: django.template.base.Template | django.template.base.Node, context: django.template.context.Context) None¶
- generic_visit(node: django.template.base.Template | django.template.base.Node, context: django.template.context.Context) None¶
- visit_BirdNode(node: django_bird.templatetags.tags.bird.BirdNode, context: django.template.context.Context) None¶
- visit_ExtendsNode(node: django.template.loader_tags.ExtendsNode, context: django.template.context.Context) None¶
- visit_IncludeNode(node: django.template.loader_tags.IncludeNode, context: django.template.context.Context) None¶
- visit_LoadNode(node: django_bird.templatetags.tags.load.LoadNode, context: django.template.context.Context) None¶
- visit_Template(template: django.template.base.Template, context: django.template.context.Context) None¶