mirror of
https://github.com/django-components/django-components.git
synced 2025-08-11 01:38:00 +00:00
feat: allow to set main JS and CSS from files + lazy-load component m… (#870)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
8fcb84c002
commit
715bf7d447
20 changed files with 1014 additions and 248 deletions
|
@ -220,7 +220,7 @@ def _filepath_to_python_module(
|
|||
# Combine with the base module path
|
||||
full_module_name = f"{root_module_path}.{module_name}" if root_module_path else module_name
|
||||
if full_module_name.endswith(".__init__"):
|
||||
full_module_name = full_module_name[:-9] # Remove the trailing `.__init__
|
||||
full_module_name = full_module_name[:-9] # Remove the trailing `.__init__`
|
||||
|
||||
return full_module_name
|
||||
|
||||
|
@ -236,3 +236,12 @@ def _search_dirs(dirs: List[Path], search_glob: str) -> List[Path]:
|
|||
matched_files.append(Path(path))
|
||||
|
||||
return matched_files
|
||||
|
||||
|
||||
def resolve_file(filepath: str, dirs: Optional[List[Path]] = None) -> Optional[Path]:
|
||||
dirs = dirs if dirs is not None else get_component_dirs()
|
||||
for directory in dirs:
|
||||
full_path = Path(directory) / filepath
|
||||
if full_path.exists():
|
||||
return full_path
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue