django-components 0.50__tar.gz → 0.51__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {django_components-0.50 → django_components-0.51}/PKG-INFO +15 -6
  2. {django_components-0.50 → django_components-0.51}/README.md +14 -5
  3. {django_components-0.50 → django_components-0.51}/django_components/template_loader.py +1 -1
  4. django_components-0.51/django_components/types.py +21 -0
  5. {django_components-0.50 → django_components-0.51}/django_components.egg-info/PKG-INFO +15 -6
  6. {django_components-0.50 → django_components-0.51}/django_components.egg-info/SOURCES.txt +1 -0
  7. {django_components-0.50 → django_components-0.51}/setup.py +1 -1
  8. {django_components-0.50 → django_components-0.51}/LICENSE +0 -0
  9. {django_components-0.50 → django_components-0.51}/django_components/__init__.py +0 -0
  10. {django_components-0.50 → django_components-0.51}/django_components/app_settings.py +0 -0
  11. {django_components-0.50 → django_components-0.51}/django_components/apps.py +0 -0
  12. {django_components-0.50 → django_components-0.51}/django_components/component.py +0 -0
  13. {django_components-0.50 → django_components-0.51}/django_components/component_registry.py +0 -0
  14. {django_components-0.50 → django_components-0.51}/django_components/management/__init__.py +0 -0
  15. {django_components-0.50 → django_components-0.51}/django_components/management/commands/__init__.py +0 -0
  16. {django_components-0.50 → django_components-0.51}/django_components/management/commands/startcomponent.py +0 -0
  17. {django_components-0.50 → django_components-0.51}/django_components/management/commands/upgradecomponent.py +0 -0
  18. {django_components-0.50 → django_components-0.51}/django_components/middleware.py +0 -0
  19. {django_components-0.50 → django_components-0.51}/django_components/safer_staticfiles/__init__.py +0 -0
  20. {django_components-0.50 → django_components-0.51}/django_components/safer_staticfiles/apps.py +0 -0
  21. {django_components-0.50 → django_components-0.51}/django_components/templatetags/__init__.py +0 -0
  22. {django_components-0.50 → django_components-0.51}/django_components/templatetags/component_tags.py +0 -0
  23. {django_components-0.50 → django_components-0.51}/django_components.egg-info/dependency_links.txt +0 -0
  24. {django_components-0.50 → django_components-0.51}/django_components.egg-info/requires.txt +0 -0
  25. {django_components-0.50 → django_components-0.51}/django_components.egg-info/top_level.txt +0 -0
  26. {django_components-0.50 → django_components-0.51}/pyproject.toml +0 -0
  27. {django_components-0.50 → django_components-0.51}/setup.cfg +0 -0
  28. {django_components-0.50 → django_components-0.51}/tests/components/__init__.py +0 -0
  29. {django_components-0.50 → django_components-0.51}/tests/components/single_file.py +0 -0
  30. {django_components-0.50 → django_components-0.51}/tests/components/urls.py +0 -0
  31. {django_components-0.50 → django_components-0.51}/tests/test_autodiscover.py +0 -0
  32. {django_components-0.50 → django_components-0.51}/tests/test_component.py +0 -0
  33. {django_components-0.50 → django_components-0.51}/tests/test_component_as_view.py +0 -0
  34. {django_components-0.50 → django_components-0.51}/tests/test_context.py +0 -0
  35. {django_components-0.50 → django_components-0.51}/tests/test_dependency_rendering.py +0 -0
  36. {django_components-0.50 → django_components-0.51}/tests/test_registry.py +0 -0
  37. {django_components-0.50 → django_components-0.51}/tests/test_settings.py +0 -0
  38. {django_components-0.50 → django_components-0.51}/tests/test_startcomponent_command.py +0 -0
  39. {django_components-0.50 → django_components-0.51}/tests/test_templatetags.py +0 -0
  40. {django_components-0.50 → django_components-0.51}/tests/testutils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django_components
3
- Version: 0.50
3
+ Version: 0.51
4
4
  Summary: A way to create simple reusable template components in Django.
5
5
  Home-page: https://github.com/EmilStenstrom/django-components/
6
6
  Author: Emil Stenström
@@ -49,7 +49,7 @@ Read on to learn about the details!
49
49
 
50
50
  ## Release notes
51
51
 
52
- <span style="color: red; font-weight: bold">**Version 0.5** CHANGES THE SYNTAX</span> for components. `component_block` is now `component`, and `component` blocks need an ending `endcomponent` tag. The new `python manage.py upgradecomponent` command can be used to upgrade a directory (use --path argument to point to each dir) of components to the new syntax automatically.
52
+ 🚨📢 **Version 0.5** CHANGES THE SYNTAX for components. `component_block` is now `component`, and `component` blocks need an ending `endcomponent` tag. The new `python manage.py upgradecomponent` command can be used to upgrade a directory (use --path argument to point to each dir) of components to the new syntax automatically.
53
53
 
54
54
  This change is done to simplify the API in anticipation of a 1.0 release of django_components. After 1.0 we intend to be stricter with big changes like this in point releases.
55
55
 
@@ -139,7 +139,7 @@ Modify STATICFILES_DIRS (or add it if you don't have it) so django can find your
139
139
  ```python
140
140
  STATICFILES_DIRS = [
141
141
  ...,
142
- BASE_DIR / "components",
142
+ os.path.join(BASE_DIR, "components"),
143
143
  ]
144
144
  ```
145
145
 
@@ -284,6 +284,7 @@ Components can also be defined in a single file, which is useful for small compo
284
284
  ```python
285
285
  # In a file called [project root]/components/calendar.py
286
286
  from django_components import component
287
+ from django_components import types as t
287
288
 
288
289
  @component.register("calendar")
289
290
  class Calendar(component.Component):
@@ -292,16 +293,16 @@ class Calendar(component.Component):
292
293
  "date": date,
293
294
  }
294
295
 
295
- template = """
296
+ template: t.django_html = """
296
297
  <div class="calendar-component">Today's date is <span>{{ date }}</span></div>
297
298
  """
298
299
 
299
- css = """
300
+ css: t.css = """
300
301
  .calendar-component { width: 200px; background: pink; }
301
302
  .calendar-component span { font-weight: bold; }
302
303
  """
303
304
 
304
- js = """
305
+ js: t.js = """
305
306
  (function(){
306
307
  if (document.querySelector(".calendar-component")) {
307
308
  document.querySelector(".calendar-component").onclick = function(){ alert("Clicked calendar!"); };
@@ -312,6 +313,8 @@ class Calendar(component.Component):
312
313
 
313
314
  This makes it easy to create small components without having to create a separate template, CSS, and JS file.
314
315
 
316
+ Note that the `t.django_html`, `t.css`, and `t.js` types are used to specify the type of the template, CSS, and JS files, respectively. This is not necessary, but if you're using VSCode with the [Python Inline Source Syntax Highlighting](https://marketplace.visualstudio.com/items?itemName=samwillis.python-inline-source) extension, it will give you syntax highlighting for the template, CSS, and JS.
317
+
315
318
  ## Using slots in templates
316
319
 
317
320
  _New in version 0.26_:
@@ -781,6 +784,12 @@ python manage.py startcomponent my_component --dry-run
781
784
 
782
785
  This will simulate the creation of `my_component` without creating any files.
783
786
 
787
+ ## Community examples
788
+
789
+ One of our goals with `django-components` is to make it easy to share components between projects. If you have a set of components that you think would be useful to others, please open a pull request to add them to the list below.
790
+
791
+ - [django-htmx-components](https://github.com/iwanalabs/django-htmx-components): A set of components for use with [htmx](https://htmx.org/). Try out the [live demo](https://dhc.iwanalabs.com/).
792
+
784
793
  ## Install locally and run the tests
785
794
 
786
795
  Start by forking the project by clicking the **Fork button** up in the right corner in the GitHub . This makes a copy of the repository in your own name. Now you can clone this repository locally and start adding features:
@@ -20,7 +20,7 @@ Read on to learn about the details!
20
20
 
21
21
  ## Release notes
22
22
 
23
- <span style="color: red; font-weight: bold">**Version 0.5** CHANGES THE SYNTAX</span> for components. `component_block` is now `component`, and `component` blocks need an ending `endcomponent` tag. The new `python manage.py upgradecomponent` command can be used to upgrade a directory (use --path argument to point to each dir) of components to the new syntax automatically.
23
+ 🚨📢 **Version 0.5** CHANGES THE SYNTAX for components. `component_block` is now `component`, and `component` blocks need an ending `endcomponent` tag. The new `python manage.py upgradecomponent` command can be used to upgrade a directory (use --path argument to point to each dir) of components to the new syntax automatically.
24
24
 
25
25
  This change is done to simplify the API in anticipation of a 1.0 release of django_components. After 1.0 we intend to be stricter with big changes like this in point releases.
26
26
 
@@ -110,7 +110,7 @@ Modify STATICFILES_DIRS (or add it if you don't have it) so django can find your
110
110
  ```python
111
111
  STATICFILES_DIRS = [
112
112
  ...,
113
- BASE_DIR / "components",
113
+ os.path.join(BASE_DIR, "components"),
114
114
  ]
115
115
  ```
116
116
 
@@ -255,6 +255,7 @@ Components can also be defined in a single file, which is useful for small compo
255
255
  ```python
256
256
  # In a file called [project root]/components/calendar.py
257
257
  from django_components import component
258
+ from django_components import types as t
258
259
 
259
260
  @component.register("calendar")
260
261
  class Calendar(component.Component):
@@ -263,16 +264,16 @@ class Calendar(component.Component):
263
264
  "date": date,
264
265
  }
265
266
 
266
- template = """
267
+ template: t.django_html = """
267
268
  <div class="calendar-component">Today's date is <span>{{ date }}</span></div>
268
269
  """
269
270
 
270
- css = """
271
+ css: t.css = """
271
272
  .calendar-component { width: 200px; background: pink; }
272
273
  .calendar-component span { font-weight: bold; }
273
274
  """
274
275
 
275
- js = """
276
+ js: t.js = """
276
277
  (function(){
277
278
  if (document.querySelector(".calendar-component")) {
278
279
  document.querySelector(".calendar-component").onclick = function(){ alert("Clicked calendar!"); };
@@ -283,6 +284,8 @@ class Calendar(component.Component):
283
284
 
284
285
  This makes it easy to create small components without having to create a separate template, CSS, and JS file.
285
286
 
287
+ Note that the `t.django_html`, `t.css`, and `t.js` types are used to specify the type of the template, CSS, and JS files, respectively. This is not necessary, but if you're using VSCode with the [Python Inline Source Syntax Highlighting](https://marketplace.visualstudio.com/items?itemName=samwillis.python-inline-source) extension, it will give you syntax highlighting for the template, CSS, and JS.
288
+
286
289
  ## Using slots in templates
287
290
 
288
291
  _New in version 0.26_:
@@ -752,6 +755,12 @@ python manage.py startcomponent my_component --dry-run
752
755
 
753
756
  This will simulate the creation of `my_component` without creating any files.
754
757
 
758
+ ## Community examples
759
+
760
+ One of our goals with `django-components` is to make it easy to share components between projects. If you have a set of components that you think would be useful to others, please open a pull request to add them to the list below.
761
+
762
+ - [django-htmx-components](https://github.com/iwanalabs/django-htmx-components): A set of components for use with [htmx](https://htmx.org/). Try out the [live demo](https://dhc.iwanalabs.com/).
763
+
755
764
  ## Install locally and run the tests
756
765
 
757
766
  Start by forking the project by clicking the **Fork button** up in the right corner in the GitHub . This makes a copy of the repository in your own name. Now you can clone this repository locally and start adding features:
@@ -15,7 +15,7 @@ class Loader(FilesystemLoader):
15
15
  directories = set(get_app_template_dirs(component_dir))
16
16
 
17
17
  if hasattr(settings, "BASE_DIR"):
18
- path = (settings.BASE_DIR / component_dir).resolve()
18
+ path = (Path(settings.BASE_DIR) / component_dir).resolve()
19
19
  if path.is_dir():
20
20
  directories.add(path)
21
21
 
@@ -0,0 +1,21 @@
1
+ try:
2
+ from typing import Annotated
3
+ except ImportError:
4
+
5
+ class Annotated:
6
+ def __init__(self, type_, *args, **kwargs):
7
+ self.type_ = type_
8
+ self.metadata = args, kwargs
9
+
10
+ def __repr__(self):
11
+ return f"Annotated[{self.type_}, {self.metadata[0]!r}, {self.metadata[1]!r}]"
12
+
13
+ def __getitem__(self, params):
14
+ if not isinstance(params, tuple):
15
+ params = (params,)
16
+ return Annotated(self.type_, *params, **self.metadata[1])
17
+
18
+
19
+ css = Annotated[str, "css"]
20
+ django_html = Annotated[str, "django_html"]
21
+ js = Annotated[str, "js"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django_components
3
- Version: 0.50
3
+ Version: 0.51
4
4
  Summary: A way to create simple reusable template components in Django.
5
5
  Home-page: https://github.com/EmilStenstrom/django-components/
6
6
  Author: Emil Stenström
@@ -49,7 +49,7 @@ Read on to learn about the details!
49
49
 
50
50
  ## Release notes
51
51
 
52
- <span style="color: red; font-weight: bold">**Version 0.5** CHANGES THE SYNTAX</span> for components. `component_block` is now `component`, and `component` blocks need an ending `endcomponent` tag. The new `python manage.py upgradecomponent` command can be used to upgrade a directory (use --path argument to point to each dir) of components to the new syntax automatically.
52
+ 🚨📢 **Version 0.5** CHANGES THE SYNTAX for components. `component_block` is now `component`, and `component` blocks need an ending `endcomponent` tag. The new `python manage.py upgradecomponent` command can be used to upgrade a directory (use --path argument to point to each dir) of components to the new syntax automatically.
53
53
 
54
54
  This change is done to simplify the API in anticipation of a 1.0 release of django_components. After 1.0 we intend to be stricter with big changes like this in point releases.
55
55
 
@@ -139,7 +139,7 @@ Modify STATICFILES_DIRS (or add it if you don't have it) so django can find your
139
139
  ```python
140
140
  STATICFILES_DIRS = [
141
141
  ...,
142
- BASE_DIR / "components",
142
+ os.path.join(BASE_DIR, "components"),
143
143
  ]
144
144
  ```
145
145
 
@@ -284,6 +284,7 @@ Components can also be defined in a single file, which is useful for small compo
284
284
  ```python
285
285
  # In a file called [project root]/components/calendar.py
286
286
  from django_components import component
287
+ from django_components import types as t
287
288
 
288
289
  @component.register("calendar")
289
290
  class Calendar(component.Component):
@@ -292,16 +293,16 @@ class Calendar(component.Component):
292
293
  "date": date,
293
294
  }
294
295
 
295
- template = """
296
+ template: t.django_html = """
296
297
  <div class="calendar-component">Today's date is <span>{{ date }}</span></div>
297
298
  """
298
299
 
299
- css = """
300
+ css: t.css = """
300
301
  .calendar-component { width: 200px; background: pink; }
301
302
  .calendar-component span { font-weight: bold; }
302
303
  """
303
304
 
304
- js = """
305
+ js: t.js = """
305
306
  (function(){
306
307
  if (document.querySelector(".calendar-component")) {
307
308
  document.querySelector(".calendar-component").onclick = function(){ alert("Clicked calendar!"); };
@@ -312,6 +313,8 @@ class Calendar(component.Component):
312
313
 
313
314
  This makes it easy to create small components without having to create a separate template, CSS, and JS file.
314
315
 
316
+ Note that the `t.django_html`, `t.css`, and `t.js` types are used to specify the type of the template, CSS, and JS files, respectively. This is not necessary, but if you're using VSCode with the [Python Inline Source Syntax Highlighting](https://marketplace.visualstudio.com/items?itemName=samwillis.python-inline-source) extension, it will give you syntax highlighting for the template, CSS, and JS.
317
+
315
318
  ## Using slots in templates
316
319
 
317
320
  _New in version 0.26_:
@@ -781,6 +784,12 @@ python manage.py startcomponent my_component --dry-run
781
784
 
782
785
  This will simulate the creation of `my_component` without creating any files.
783
786
 
787
+ ## Community examples
788
+
789
+ One of our goals with `django-components` is to make it easy to share components between projects. If you have a set of components that you think would be useful to others, please open a pull request to add them to the list below.
790
+
791
+ - [django-htmx-components](https://github.com/iwanalabs/django-htmx-components): A set of components for use with [htmx](https://htmx.org/). Try out the [live demo](https://dhc.iwanalabs.com/).
792
+
784
793
  ## Install locally and run the tests
785
794
 
786
795
  Start by forking the project by clicking the **Fork button** up in the right corner in the GitHub . This makes a copy of the repository in your own name. Now you can clone this repository locally and start adding features:
@@ -9,6 +9,7 @@ django_components/component.py
9
9
  django_components/component_registry.py
10
10
  django_components/middleware.py
11
11
  django_components/template_loader.py
12
+ django_components/types.py
12
13
  django_components.egg-info/PKG-INFO
13
14
  django_components.egg-info/SOURCES.txt
14
15
  django_components.egg-info/dependency_links.txt
@@ -3,7 +3,7 @@ import os
3
3
 
4
4
  from setuptools import find_packages, setup
5
5
 
6
- VERSION = "0.50"
6
+ VERSION = "0.51"
7
7
 
8
8
  setup(
9
9
  name="django_components",