mirror of
https://github.com/django-components/django-components.git
synced 2025-07-19 06:15:00 +00:00
Class decorator and test
This commit is contained in:
parent
bb3193cd4c
commit
10a117ee88
2 changed files with 25 additions and 0 deletions
|
@ -97,3 +97,20 @@ def is_slot_node(node):
|
|||
|
||||
# This variable represents the global component registry
|
||||
registry = ComponentRegistry()
|
||||
|
||||
def register(name):
|
||||
"""Class decorator to register a component.
|
||||
|
||||
|
||||
Usage:
|
||||
|
||||
@register("my_component")
|
||||
class MyComponent(component.Component):
|
||||
...
|
||||
|
||||
"""
|
||||
def decorator(component):
|
||||
registry.register(name=name, component=component)
|
||||
return component
|
||||
|
||||
return decorator
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue