mirror of
https://github.com/django-components/django-components.git
synced 2025-08-14 11:17:59 +00:00
Multi-line tag support, watch component files, and cleanup (#624)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
b26a201138
commit
ab059f362d
8 changed files with 217 additions and 50 deletions
|
@ -1,4 +1,7 @@
|
|||
from typing import Any, Callable, List
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, List, Sequence, Union
|
||||
|
||||
from django.utils.autoreload import autoreload_started
|
||||
|
||||
# Global counter to ensure that all IDs generated by `gen_id` WILL be unique
|
||||
_id = 0
|
||||
|
@ -23,3 +26,13 @@ def find_last_index(lst: List, predicate: Callable[[Any], bool]) -> Any:
|
|||
|
||||
def is_str_wrapped_in_quotes(s: str) -> bool:
|
||||
return s.startswith(('"', "'")) and s[0] == s[-1] and len(s) >= 2
|
||||
|
||||
|
||||
# See https://github.com/EmilStenstrom/django-components/issues/586#issue-2472678136
|
||||
def watch_files_for_autoreload(watch_list: Sequence[Union[str, Path]]) -> None:
|
||||
def autoreload_hook(sender: Any, *args: Any, **kwargs: Any) -> None:
|
||||
watch = sender.extra_files.add
|
||||
for file in watch_list:
|
||||
watch(Path(file))
|
||||
|
||||
autoreload_started.connect(autoreload_hook)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue