mirror of
https://github.com/django-components/django-components.git
synced 2025-08-09 00:37:59 +00:00
refactor: Use top-level exports as public API (#562)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
d819f3ff49
commit
e771a0aaaf
30 changed files with 615 additions and 598 deletions
|
@ -15,16 +15,7 @@ from django.utils.safestring import SafeString, mark_safe
|
|||
from django.views import View
|
||||
|
||||
from django_components.component_media import ComponentMediaInput, MediaMeta
|
||||
|
||||
# Global registry var and register() function moved to separate module.
|
||||
# Defining them here made little sense, since 1) component_tags.py and component.py
|
||||
# rely on them equally, and 2) it made it difficult to avoid circularity in the
|
||||
# way the two modules depend on one another.
|
||||
from django_components.component_registry import AlreadyRegistered as AlreadyRegistered # NOQA
|
||||
from django_components.component_registry import ComponentRegistry as ComponentRegistry # NOQA
|
||||
from django_components.component_registry import NotRegistered as NotRegistered # NOQA
|
||||
from django_components.component_registry import register as register # NOQA
|
||||
from django_components.component_registry import registry # NOQA
|
||||
from django_components.component_registry import registry
|
||||
from django_components.context import (
|
||||
_FILLED_SLOTS_CONTENT_CONTEXT_KEY,
|
||||
_PARENT_COMP_CONTEXT_KEY,
|
||||
|
@ -50,6 +41,16 @@ from django_components.slots import (
|
|||
from django_components.template_parser import process_aggregate_kwargs
|
||||
from django_components.utils import gen_id
|
||||
|
||||
# TODO_DEPRECATE_V1 - REMOVE IN V1, users should use top-level import instead
|
||||
# isort: off
|
||||
from django_components.component_registry import AlreadyRegistered as AlreadyRegistered # NOQA
|
||||
from django_components.component_registry import ComponentRegistry as ComponentRegistry # NOQA
|
||||
from django_components.component_registry import NotRegistered as NotRegistered # NOQA
|
||||
from django_components.component_registry import register as register # NOQA
|
||||
from django_components.component_registry import registry as registry # NOQA
|
||||
|
||||
# isort: on
|
||||
|
||||
RENDERED_COMMENT_TEMPLATE = "<!-- _RENDERED {name} -->"
|
||||
|
||||
|
||||
|
@ -202,8 +203,10 @@ class Component(View, metaclass=ComponentMeta):
|
|||
|
||||
And given this definition of "my_comp" component:
|
||||
```py
|
||||
@component.register("my_comp")
|
||||
class MyComp(component.Component):
|
||||
from django_components import Component, register
|
||||
|
||||
@register("my_comp")
|
||||
class MyComp(Component):
|
||||
template = "hi {{ data.hello }}!"
|
||||
def get_context_data(self):
|
||||
data = self.inject("provider")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue