diff --git a/README.md b/README.md index 60b1ab6..d87fd1a 100644 --- a/README.md +++ b/README.md @@ -474,6 +474,10 @@ In addition, Cotton enables you to navigate around some of the limitations with The directory where your components are stored. +`COTTON_BASE_DIR` (default: None) + +The directory that contains your project-level "templates" directory. + `COTTON_SNAKE_CASED_NAMES` (default: True) Whether to search for component filenames in snake_case. If set to False, you can use kebab-cased / hyphenated filenames. diff --git a/django_cotton/cotton_loader.py b/django_cotton/cotton_loader.py index ef550af..e3a7ca6 100755 --- a/django_cotton/cotton_loader.py +++ b/django_cotton/cotton_loader.py @@ -61,9 +61,14 @@ class Loader(BaseLoader): dirs.append(template_dir) # Check project root templates, e.g. project/templates - root_template_dir = os.path.join(settings.BASE_DIR, "templates") - if os.path.isdir(root_template_dir): - dirs.append(root_template_dir) + base_dir = getattr(settings, "COTTON_BASE_DIR", None) + if base_dir is None: + base_dir = getattr(settings, "BASE_DIR", None) + + if base_dir is not None: + root_template_dir = os.path.join(base_dir, "templates") + if os.path.isdir(root_template_dir): + dirs.append(root_template_dir) return dirs diff --git a/docs/docs_project/docs_project/templates/configuration.html b/docs/docs_project/docs_project/templates/configuration.html index 6f096a4..e49565c 100644 --- a/docs/docs_project/docs_project/templates/configuration.html +++ b/docs/docs_project/docs_project/templates/configuration.html @@ -13,6 +13,17 @@ +
COTTON_BASE_DIR
+ [project]/[app]/templates/cotton/row.html
[project]/templates/cotton/row.html
[project]/templates/cotton/row.html
[project]
depends on the `BASE_DIR` or `COTTON_BASE_DIR` settings)
+ Any style will allow you to include your component the same way: {{ '