django-components/tests/components/glob/glob.py
Juro Oravec f100cc1836
Some checks are pending
Docs - build & deploy / docs (push) Waiting to run
Run tests / build (ubuntu-latest, 3.10) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.11) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.12) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.8) (push) Waiting to run
Run tests / test_sampleproject (3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.9) (push) Waiting to run
Run tests / build (windows-latest, 3.10) (push) Waiting to run
Run tests / build (windows-latest, 3.11) (push) Waiting to run
Run tests / build (windows-latest, 3.12) (push) Waiting to run
Run tests / build (windows-latest, 3.13) (push) Waiting to run
Run tests / build (windows-latest, 3.8) (push) Waiting to run
Run tests / build (windows-latest, 3.9) (push) Waiting to run
Run tests / test_docs (3.13) (push) Waiting to run
refactor: replace isort, black and flake8 with ruff (#1346)
2025-09-10 14:06:53 +02:00

76 lines
2.3 KiB
Python

from django_components import Component
# The Media JS / CSS glob and are relative to the component directory
class GlobComponent(Component):
template = """
{% load component_tags %}
{% component_js_dependencies %}
{% component_css_dependencies %}
"""
class Media:
css = "glob_*.css"
js = "glob_*.js"
# The Media JS / CSS glob and are relative to the directory given in
# `COMPONENTS.dirs` and `COMPONENTS.app_dirs`
class GlobComponentRootDir(GlobComponent):
class Media:
css = "glob/glob_*.css"
js = "glob/glob_*.js"
# The Media JS / CSS are NOT globs and are relative to the directory given in
# `COMPONENTS.dirs` and `COMPONENTS.app_dirs`. These should NOT be modified.
class NonGlobComponentRootDir(Component):
template = """
{% load component_tags %}
{% component_js_dependencies %}
{% component_css_dependencies %}
"""
class Media:
css = "glob/glob_1.css"
js = "glob/glob_1.js"
# The Media JS / CSS are NOT globs. While relative to the directory given in
# `COMPONENTS.dirs` and `COMPONENTS.app_dirs`, these files do not exist.
# These paths should NOT be modified.
class NonGlobNonexistComponentRootDir(Component):
template = """
{% load component_tags %}
{% component_js_dependencies %}
{% component_css_dependencies %}
"""
class Media:
css = "glob/glob_nonexist.css"
js = "glob/glob_nonexist.js"
# The Media JS / CSS are NOT globs, but URLs.
class UrlComponent(Component):
template = """
{% load component_tags %}
{% component_js_dependencies %}
{% component_css_dependencies %}
"""
class Media:
css = [
"https://example.com/example/style.min.css",
"http://example.com/example/style.min.css",
# :// is not a valid URL - will be resolved as static path
"://example.com/example/style.min.css",
"/path/to/style.css",
]
js = [
"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.0.2/chart.min.js",
"http://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.0.2/chart.min.js",
# :// is not a valid URL - will be resolved as static path
"://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.0.2/chart.min.js",
"/path/to/script.js",
]