refactor: change repo name and URL after org migration (#924)

This commit is contained in:
Juro Oravec 2025-01-22 16:02:46 +01:00 committed by GitHub
parent ace9194733
commit 92f5497c74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 134 additions and 119 deletions

View file

@ -25,7 +25,7 @@ jobs:
id-token: write # to verify the deployment originates from an appropriate source id-token: write # to verify the deployment originates from an appropriate source
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Only run in original repo (not in forks) # Only run in original repo (not in forks)
if: github.repository == 'EmilStenstrom/django-components' if: github.repository == 'django-components/django-components'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4

View file

@ -12,7 +12,7 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository == 'EmilStenstrom/django-components' if: github.repository == 'django-components/django-components'
steps: steps:
- name: Checkout the repo - name: Checkout the repo
uses: actions/checkout@v2 uses: actions/checkout@v2

View file

@ -2,12 +2,18 @@
## v0.125 ## v0.125
⚠️ Attention ⚠️ - We migrated from `EmilStenstrom/django-components` to `django-components/django-components`.
**Repo name and documentation URL changed. Package name remains the same.**
If you see any broken links or other issues, please report them in [#922](https://github.com/django-components/django-components/issues/922).
#### Feat #### Feat
- `@template_tag` and `BaseNode` - A decorator and a class that allow you to define - `@template_tag` and `BaseNode` - A decorator and a class that allow you to define
custom template tags that will behave similarly to django-components' own template tags. custom template tags that will behave similarly to django-components' own template tags.
Read more on [Template tags](https://EmilStenstrom.github.io/django-components/0.125/concepts/advanced/template_tags/). Read more on [Template tags](https://django-components.github.io/django-components/0.125/concepts/advanced/template_tags/).
Template tags defined with `@template_tag` and `BaseNode` will have the following features: Template tags defined with `@template_tag` and `BaseNode` will have the following features:
@ -79,7 +85,7 @@
- The JS/CSS defined in `Component.js/css` or `Component.js/css_file` is the "main" JS/CSS - The JS/CSS defined in `Component.js/css` or `Component.js/css_file` is the "main" JS/CSS
- The JS/CSS defined in `Component.Media.js/css` are secondary or additional - The JS/CSS defined in `Component.Media.js/css` are secondary or additional
See the updated ["Getting Started" tutorial](https://EmilStenstrom.github.io/django-components/0.124/getting_started/adding_js_and_css/) See the updated ["Getting Started" tutorial](https://django-components.github.io/django-components/0.124/getting_started/adding_js_and_css/)
#### Refactor #### Refactor
@ -100,7 +106,7 @@
1. Try to access component's HTML / CSS / JS, or 1. Try to access component's HTML / CSS / JS, or
2. Render the component. 2. Render the component.
Read more on [Accessing component's HTML / JS / CSS](https://EmilStenstrom.github.io/django-components/0.124/concepts/fundamentals/defining_js_css_html_files/#customize-how-paths-are-rendered-into-html-tags). Read more on [Accessing component's HTML / JS / CSS](https://django-components.github.io/django-components/0.124/concepts/fundamentals/defining_js_css_html_files/#customize-how-paths-are-rendered-into-html-tags).
- Component inheritance: - Component inheritance:
@ -116,19 +122,19 @@
#### Fix #### Fix
- Fix edge cases around rendering components whose templates used the `{% extends %}` template tag ([#859](https://github.com/EmilStenstrom/django-components/pull/859)) - Fix edge cases around rendering components whose templates used the `{% extends %}` template tag ([#859](https://github.com/django-components/django-components/pull/859))
## v0.122 ## v0.122
#### Feat #### Feat
- Add support for HTML fragments. HTML fragments can be rendered by passing `type="fragment"` to `Component.render()` or `Component.render_to_response()`. Read more on how to [use HTML fragments with HTMX, AlpineJS, or vanillaJS](https://EmilStenstrom.github.io/django-components/latest/concepts/advanced/html_tragments). - Add support for HTML fragments. HTML fragments can be rendered by passing `type="fragment"` to `Component.render()` or `Component.render_to_response()`. Read more on how to [use HTML fragments with HTMX, AlpineJS, or vanillaJS](https://django-components.github.io/django-components/latest/concepts/advanced/html_tragments).
## v0.121 ## v0.121
#### Fix #### Fix
- Fix the use of Django template filters (`|lower:"etc"`) with component inputs [#855](https://github.com/EmilStenstrom/django-components/pull/855). - Fix the use of Django template filters (`|lower:"etc"`) with component inputs [#855](https://github.com/django-components/django-components/pull/855).
## v0.120 ## v0.120
@ -136,23 +142,23 @@
#### Fix #### Fix
- Fix the use of translation strings `_("bla")` as inputs to components [#849](https://github.com/EmilStenstrom/django-components/pull/849). - Fix the use of translation strings `_("bla")` as inputs to components [#849](https://github.com/django-components/django-components/pull/849).
## v0.119 ## v0.119
⚠️ Attention ⚠️ - This release introduced bugs [#849](https://github.com/EmilStenstrom/django-components/pull/849), [#855](https://github.com/EmilStenstrom/django-components/pull/855). Please update to v0.121. ⚠️ Attention ⚠️ - This release introduced bugs [#849](https://github.com/django-components/django-components/pull/849), [#855](https://github.com/django-components/django-components/pull/855). Please update to v0.121.
#### Fix #### Fix
- Fix compatibility with custom subclasses of Django's `Template` that need to access - Fix compatibility with custom subclasses of Django's `Template` that need to access
`origin` or other initialization arguments. (https://github.com/EmilStenstrom/django-components/pull/828) `origin` or other initialization arguments. (https://github.com/django-components/django-components/pull/828)
#### Refactor #### Refactor
- Compatibility with `django-debug-toolbar-template-profiler`: - Compatibility with `django-debug-toolbar-template-profiler`:
- Monkeypatching of Django's `Template` now happens at `AppConfig.ready()` (https://github.com/EmilStenstrom/django-components/pull/825) - Monkeypatching of Django's `Template` now happens at `AppConfig.ready()` (https://github.com/django-components/django-components/pull/825)
- Internal parsing of template tags tag was updated. No API change. (https://github.com/EmilStenstrom/django-components/pull/827) - Internal parsing of template tags tag was updated. No API change. (https://github.com/django-components/django-components/pull/827)
## v0.118 ## v0.118
@ -187,7 +193,7 @@
## v0.116 ## v0.116
⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/EmilStenstrom/django-components/issues/791) and [#789](https://github.com/EmilStenstrom/django-components/issues/789) and [#818](https://github.com/EmilStenstrom/django-components/issues/818). ⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/django-components/django-components/issues/791) and [#789](https://github.com/django-components/django-components/issues/789) and [#818](https://github.com/django-components/django-components/issues/818).
#### Fix #### Fix
@ -234,7 +240,7 @@
## v0.115 ## v0.115
⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/EmilStenstrom/django-components/issues/791) and [#789](https://github.com/EmilStenstrom/django-components/issues/789) and [#818](https://github.com/EmilStenstrom/django-components/issues/818). ⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/django-components/django-components/issues/791) and [#789](https://github.com/django-components/django-components/issues/789) and [#818](https://github.com/django-components/django-components/issues/818).
#### Fix #### Fix
@ -243,7 +249,7 @@
## v0.114 ## v0.114
⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/EmilStenstrom/django-components/issues/791) and [#789](https://github.com/EmilStenstrom/django-components/issues/789) and [#818](https://github.com/EmilStenstrom/django-components/issues/818). ⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/django-components/django-components/issues/791) and [#789](https://github.com/django-components/django-components/issues/789) and [#818](https://github.com/django-components/django-components/issues/818).
#### Fix #### Fix
@ -252,7 +258,7 @@
## v0.113 ## v0.113
⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/EmilStenstrom/django-components/issues/791) and [#789](https://github.com/EmilStenstrom/django-components/issues/789) and [#818](https://github.com/EmilStenstrom/django-components/issues/818). ⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/django-components/django-components/issues/791) and [#789](https://github.com/django-components/django-components/issues/789) and [#818](https://github.com/django-components/django-components/issues/818).
#### Fix #### Fix
@ -260,7 +266,7 @@
## v0.112 ## v0.112
⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/EmilStenstrom/django-components/issues/791) and [#789](https://github.com/EmilStenstrom/django-components/issues/789) and [#818](https://github.com/EmilStenstrom/django-components/issues/818). ⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/django-components/django-components/issues/791) and [#789](https://github.com/django-components/django-components/issues/789) and [#818](https://github.com/django-components/django-components/issues/818).
#### Fix #### Fix
@ -268,7 +274,7 @@
## v0.111 ## v0.111
⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/EmilStenstrom/django-components/issues/791) and [#789](https://github.com/EmilStenstrom/django-components/issues/789) and [#818](https://github.com/EmilStenstrom/django-components/issues/818). ⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/django-components/django-components/issues/791) and [#789](https://github.com/django-components/django-components/issues/789) and [#818](https://github.com/django-components/django-components/issues/818).
#### Fix #### Fix
@ -277,7 +283,7 @@
## 🚨📢 v0.110 ## 🚨📢 v0.110
⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/EmilStenstrom/django-components/issues/791) and [#789](https://github.com/EmilStenstrom/django-components/issues/789) and [#818](https://github.com/EmilStenstrom/django-components/issues/818). ⚠️ Attention ⚠️ - Please update to v0.117 to fix known bugs. See [#791](https://github.com/django-components/django-components/issues/791) and [#789](https://github.com/django-components/django-components/issues/789) and [#818](https://github.com/django-components/django-components/issues/818).
### General ### General
@ -286,7 +292,7 @@
- Installation changes: - Installation changes:
- If your components include JS or CSS, you now must use the middleware and add django-components' URLs to your `urlpatterns` - If your components include JS or CSS, you now must use the middleware and add django-components' URLs to your `urlpatterns`
(See "[Adding support for JS and CSS](https://github.com/EmilStenstrom/django-components#adding-support-for-js-and-css)") (See "[Adding support for JS and CSS](https://github.com/django-components/django-components#adding-support-for-js-and-css)")
- Component typing signature changed from - Component typing signature changed from
@ -337,7 +343,7 @@ importing them.
#### Refactor #### Refactor
- For advanced use cases, use can omit the middleware and instead manage component JS and CSS dependencies yourself with [`render_dependencies`](https://github.com/EmilStenstrom/django-components#render_dependencies-and-deep-dive-into-rendering-js--css-without-the-middleware) - For advanced use cases, use can omit the middleware and instead manage component JS and CSS dependencies yourself with [`render_dependencies`](https://github.com/django-components/django-components#render_dependencies-and-deep-dive-into-rendering-js--css-without-the-middleware)
- The [`ComponentRegistry`](../api#django_components.ComponentRegistry) settings [`RegistrySettings`](../api#django_components.RegistrySettings) - The [`ComponentRegistry`](../api#django_components.ComponentRegistry) settings [`RegistrySettings`](../api#django_components.RegistrySettings)
were lowercased to align with the global settings: were lowercased to align with the global settings:
@ -607,15 +613,15 @@ importing them.
- Installation changes: - Installation changes:
- Instead of defining component directories in `STATICFILES_DIRS`, set them to [`COMPONENTS.dirs`](https://github.com/EmilStenstrom/django-components#dirs). - Instead of defining component directories in `STATICFILES_DIRS`, set them to [`COMPONENTS.dirs`](https://github.com/django-components/django-components#dirs).
- You now must define `STATICFILES_FINDERS` - You now must define `STATICFILES_FINDERS`
- [See here how to migrate your settings.py](https://github.com/EmilStenstrom/django-components/blob/master/docs/migrating_from_safer_staticfiles.md) - [See here how to migrate your settings.py](https://github.com/django-components/django-components/blob/master/docs/migrating_from_safer_staticfiles.md)
#### Feat #### Feat
- Beside the top-level `/components` directory, you can now define also app-level components dirs, e.g. `[app]/components` - Beside the top-level `/components` directory, you can now define also app-level components dirs, e.g. `[app]/components`
(See [`COMPONENTS.app_dirs`](https://github.com/EmilStenstrom/django-components#app_dirs)). (See [`COMPONENTS.app_dirs`](https://github.com/django-components/django-components#app_dirs)).
#### Refactor #### Refactor
@ -625,7 +631,7 @@ importing them.
#### Fix #### Fix
- Fixed template caching. You can now also manually create cached templates with [`cached_template()`](https://github.com/EmilStenstrom/django-components#template_cache_size---tune-the-template-cache) - Fixed template caching. You can now also manually create cached templates with [`cached_template()`](https://github.com/django-components/django-components#template_cache_size---tune-the-template-cache)
#### Refactor #### Refactor
@ -640,9 +646,9 @@ importing them.
#### Feat #### Feat
- Run-time type validation for Python 3.11+ - If the `Component` class is typed, e.g. `Component[Args, Kwargs, ...]`, the args, kwargs, slots, and data are validated against the given types. (See [Runtime input validation with types](https://github.com/EmilStenstrom/django-components#runtime-input-validation-with-types)) - Run-time type validation for Python 3.11+ - If the `Component` class is typed, e.g. `Component[Args, Kwargs, ...]`, the args, kwargs, slots, and data are validated against the given types. (See [Runtime input validation with types](https://github.com/django-components/django-components#runtime-input-validation-with-types))
- Render hooks - Set `on_render_before` and `on_render_after` methods on `Component` to intercept or modify the template or context before rendering, or the rendered result afterwards. (See [Component hooks](https://github.com/EmilStenstrom/django-components#component-hooks)) - Render hooks - Set `on_render_before` and `on_render_after` methods on `Component` to intercept or modify the template or context before rendering, or the rendered result afterwards. (See [Component hooks](https://github.com/django-components/django-components#component-hooks))
- `component_vars.is_filled` context variable can be accessed from within `on_render_before` and `on_render_after` hooks as `self.is_filled.my_slot` - `component_vars.is_filled` context variable can be accessed from within `on_render_before` and `on_render_after` hooks as `self.is_filled.my_slot`
@ -650,7 +656,7 @@ importing them.
#### Feat #### Feat
- Added support for dynamic components, where the component name is passed as a variable. (See [Dynamic components](https://github.com/EmilStenstrom/django-components#dynamic-components)) - Added support for dynamic components, where the component name is passed as a variable. (See [Dynamic components](https://github.com/django-components/django-components#dynamic-components))
#### Refactor #### Refactor
@ -660,17 +666,17 @@ importing them.
#### Feat #### Feat
- django_components now automatically configures Django to support multi-line tags. (See [Multi-line tags](https://github.com/EmilStenstrom/django-components#multi-line-tags)) - django_components now automatically configures Django to support multi-line tags. (See [Multi-line tags](https://github.com/django-components/django-components#multi-line-tags))
- New setting `reload_on_template_change`. Set this to `True` to reload the dev server on changes to component template files. (See [Reload dev server on component file changes](https://github.com/EmilStenstrom/django-components#reload-dev-server-on-component-file-changes)) - New setting `reload_on_template_change`. Set this to `True` to reload the dev server on changes to component template files. (See [Reload dev server on component file changes](https://github.com/django-components/django-components#reload-dev-server-on-component-file-changes))
## v0.93 ## v0.93
#### Feat #### Feat
- Spread operator `...dict` inside template tags. (See [Spread operator](https://github.com/EmilStenstrom/django-components#spread-operator)) - Spread operator `...dict` inside template tags. (See [Spread operator](https://github.com/django-components/django-components#spread-operator))
- Use template tags inside string literals in component inputs. (See [Use template tags inside component inputs](https://github.com/EmilStenstrom/django-components#use-template-tags-inside-component-inputs)) - Use template tags inside string literals in component inputs. (See [Use template tags inside component inputs](https://github.com/django-components/django-components#use-template-tags-inside-component-inputs))
- Dynamic slots, fills and provides - The `name` argument for these can now be a variable, a template expression, or via spread operator - Dynamic slots, fills and provides - The `name` argument for these can now be a variable, a template expression, or via spread operator
@ -680,13 +686,13 @@ importing them.
#### BREAKING CHANGES #### BREAKING CHANGES
- `Component` class is no longer a subclass of `View`. To configure the `View` class, set the `Component.View` nested class. HTTP methods like `get` or `post` can still be defined directly on `Component` class, and `Component.as_view()` internally calls `Component.View.as_view()`. (See [Modifying the View class](https://github.com/EmilStenstrom/django-components#modifying-the-view-class)) - `Component` class is no longer a subclass of `View`. To configure the `View` class, set the `Component.View` nested class. HTTP methods like `get` or `post` can still be defined directly on `Component` class, and `Component.as_view()` internally calls `Component.View.as_view()`. (See [Modifying the View class](https://github.com/django-components/django-components#modifying-the-view-class))
#### Feat #### Feat
- The inputs (args, kwargs, slots, context, ...) that you pass to `Component.render()` can be accessed from within `get_context_data`, `get_template` and `get_template_name` via `self.input`. (See [Accessing data passed to the component](https://github.com/EmilStenstrom/django-components#accessing-data-passed-to-the-component)) - The inputs (args, kwargs, slots, context, ...) that you pass to `Component.render()` can be accessed from within `get_context_data`, `get_template` and `get_template_name` via `self.input`. (See [Accessing data passed to the component](https://github.com/django-components/django-components#accessing-data-passed-to-the-component))
- Typing: `Component` class supports generics that specify types for `Component.render` (See [Adding type hints with Generics](https://github.com/EmilStenstrom/django-components#adding-type-hints-with-generics)) - Typing: `Component` class supports generics that specify types for `Component.render` (See [Adding type hints with Generics](https://github.com/django-components/django-components#adding-type-hints-with-generics))
## v0.90 ## v0.90
@ -707,7 +713,7 @@ importing them.
{% component "button" attrs:class="hidden" %} {% component "button" attrs:class="hidden" %}
``` ```
- You can change how the components are written in the template with [TagFormatter](https://github.com/EmilStenstrom/django-components#customizing-component-tags-with-tagformatter). - You can change how the components are written in the template with [TagFormatter](https://github.com/django-components/django-components#customizing-component-tags-with-tagformatter).
The default is `django_components.component_formatter`: The default is `django_components.component_formatter`:
@ -764,7 +770,7 @@ importing them.
#### BREAKING CHANGES #### BREAKING CHANGES
- Default value for the `COMPONENTS.context_behavior` setting was changes from `"isolated"` to `"django"`. If you did not set this value explicitly before, this may be a breaking change. See the rationale for change [here](https://github.com/EmilStenstrom/django-components/issues/498). - Default value for the `COMPONENTS.context_behavior` setting was changes from `"isolated"` to `"django"`. If you did not set this value explicitly before, this may be a breaking change. See the rationale for change [here](https://github.com/django-components/django-components/issues/498).
## 🚨📢 v0.77 ## 🚨📢 v0.77
@ -801,13 +807,13 @@ importing them.
- `{% if_filled "my_slot" %}` tags were replaced with `{{ component_vars.is_filled.my_slot }}` variables. - `{% if_filled "my_slot" %}` tags were replaced with `{{ component_vars.is_filled.my_slot }}` variables.
- Simplified settings - `slot_context_behavior` and `context_behavior` were merged. See the [documentation](https://github.com/EmilStenstrom/django-components#context-behavior) for more details. - Simplified settings - `slot_context_behavior` and `context_behavior` were merged. See the [documentation](https://github.com/django-components/django-components#context-behavior) for more details.
## v0.67 ## v0.67
#### Refactor #### Refactor
- Changed the default way how context variables are resolved in slots. See the [documentation](https://github.com/EmilStenstrom/django-components/tree/0.67#isolate-components-slots) for more details. - Changed the default way how context variables are resolved in slots. See the [documentation](https://github.com/django-components/django-components/tree/0.67#isolate-components-slots) for more details.
## 🚨📢 v0.50 ## 🚨📢 v0.50
@ -823,7 +829,7 @@ importing them.
#### Feat #### Feat
- Components as views, which allows you to handle requests and render responses from within a component. See the [documentation](https://github.com/EmilStenstrom/django-components#use-components-as-views) for more details. - Components as views, which allows you to handle requests and render responses from within a component. See the [documentation](https://github.com/django-components/django-components#use-components-as-views) for more details.
## v0.28 ## v0.28
@ -835,7 +841,7 @@ importing them.
#### Feat #### Feat
- A second installable app `django_components.safer_staticfiles`. It provides the same behavior as `django.contrib.staticfiles` but with extra security guarantees (more info below in [Security Notes](https://github.com/EmilStenstrom/django-components#security-notes)). - A second installable app `django_components.safer_staticfiles`. It provides the same behavior as `django.contrib.staticfiles` but with extra security guarantees (more info below in [Security Notes](https://github.com/django-components/django-components#security-notes)).
## 🚨📢 v0.26 ## 🚨📢 v0.26

View file

@ -1,8 +1,15 @@
# <img src="https://raw.githubusercontent.com/EmilStenstrom/django-components/master/logo/logo-black-on-white.svg" alt="django-components" style="max-width: 100%; background: white; color: black;"> # <img src="https://raw.githubusercontent.com/django-components/django-components/master/logo/logo-black-on-white.svg" alt="django-components" style="max-width: 100%; background: white; color: black;">
[![PyPI - Version](https://img.shields.io/pypi/v/django-components)](https://pypi.org/project/django-components/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-components)](https://pypi.org/project/django-components/) [![PyPI - License](https://img.shields.io/pypi/l/django-components)](https://github.com/EmilStenstrom/django-components/blob/master/LICENSE/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/django-components)](https://pypistats.org/packages/django-components) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/EmilStenstrom/django-components/tests.yml)](https://github.com/EmilStenstrom/django-components/actions/workflows/tests.yml) [![PyPI - Version](https://img.shields.io/pypi/v/django-components)](https://pypi.org/project/django-components/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-components)](https://pypi.org/project/django-components/) [![PyPI - License](https://img.shields.io/pypi/l/django-components)](https://github.com/django-components/django-components/blob/master/LICENSE/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/django-components)](https://pypistats.org/packages/django-components) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/django-components/django-components/tests.yml)](https://github.com/django-components/django-components/actions/workflows/tests.yml)
### <table><td>[Read the full documentation](https://EmilStenstrom.github.io/django-components/latest/)</td></table> ### <table><td>[Read the full documentation](https://django-components.github.io/django-components/latest/)</td></table>
<!-- TODO - Remove this banner after a month(?), so March 2025 -->
> ⚠️ Attention ⚠️ - We migrated from `EmilStenstrom/django-components` to `django-components/django-components`.
>
> **Repo name and documentation URL changed. Package name remains the same.**
>
> Report any broken links links in [#922](https://github.com/django-components/django-components/issues/922).
Django-components is a package that introduces component-based architecture to Django's server-side rendering. It aims to combine Django's templating system with the modularity seen in modern frontend frameworks. Django-components is a package that introduces component-based architecture to Django's server-side rendering. It aims to combine Django's templating system with the modularity seen in modern frontend frameworks.
@ -127,13 +134,13 @@ And this is what gets rendered:
<div class="calendar-component">Today's date is <span>2024-11-06</span></div> <div class="calendar-component">Today's date is <span>2024-11-06</span></div>
``` ```
### <table><td>[Read the full documentation](https://EmilStenstrom.github.io/django-components/latest/)</td></table> ### <table><td>[Read the full documentation](https://django-components.github.io/django-components/latest/)</td></table>
... or jump right into the code, [check out the example project](https://github.com/EmilStenstrom/django-components/tree/master/sampleproject)) ... or jump right into the code, [check out the example project](https://github.com/django-components/django-components/tree/master/sampleproject))
## Release notes ## Release notes
Read the [Release Notes](https://github.com/EmilStenstrom/django-components/tree/master/CHANGELOG.md) Read the [Release Notes](https://github.com/django-components/django-components/tree/master/CHANGELOG.md)
to see the latest features and fixes. to see the latest features and fixes.
## Community examples ## Community examples
@ -146,6 +153,6 @@ One of our goals with `django-components` is to make it easy to share components
## Contributing and development ## Contributing and development
Get involved or sponsor this project - [See here](https://emilstenstrom.github.io/django-components/dev/overview/contributing/) Get involved or sponsor this project - [See here](https://django-components.github.io/django-components/dev/overview/contributing/)
Running django-components locally for development - [See here](https://emilstenstrom.github.io/django-components/dev/overview/development/) Running django-components locally for development - [See here](https://django-components.github.io/django-components/dev/overview/development/)

View file

@ -64,7 +64,7 @@ that accept a list of items via a slot.
In the example below, each `tab_item` component will be rendered on a separate tab page, but they are all defined in the default slot of the `tabs` component. In the example below, each `tab_item` component will be rendered on a separate tab page, but they are all defined in the default slot of the `tabs` component.
[See here for how it was done](https://github.com/EmilStenstrom/django-components/discussions/540) [See here for how it was done](https://github.com/django-components/django-components/discussions/540)
```django ```django
{% component "tabs" %} {% component "tabs" %}

View file

@ -31,7 +31,7 @@ As the name suggest, using provide / inject consists of 2 steps
1. Providing data 1. Providing data
2. Injecting provided data 2. Injecting provided data
For examples of advanced uses of provide / inject, [see this discussion](https://github.com/EmilStenstrom/django-components/pull/506#issuecomment-2132102584). For examples of advanced uses of provide / inject, [see this discussion](https://github.com/django-components/django-components/pull/506#issuecomment-2132102584).
## Using `{% provide %}` tag ## Using `{% provide %}` tag

View file

@ -9,7 +9,7 @@ To configure logging for Django components, set the `django_components` logger i
[`LOGGING`](https://docs.djangoproject.com/en/5.1/ref/settings/#std-setting-LOGGING) [`LOGGING`](https://docs.djangoproject.com/en/5.1/ref/settings/#std-setting-LOGGING)
in `settings.py` (below). in `settings.py` (below).
Also see the [`settings.py` file in sampleproject](https://github.com/EmilStenstrom/django-components/blob/master/sampleproject/sampleproject/settings.py) for a real-life example. Also see the [`settings.py` file in sampleproject](https://github.com/django-components/django-components/blob/master/sampleproject/sampleproject/settings.py) for a real-life example.
```py ```py
import logging import logging

View file

@ -4,7 +4,7 @@ This guide is for you if you're upgrating django_components to v0.100 or later
from older versions. from older versions.
In version 0.100, we changed how components' static JS and CSS files are handled. In version 0.100, we changed how components' static JS and CSS files are handled.
See more in the ["Static files" section](https://github.com/EmilStenstrom/django-components/tree/master/sampleproject). See more in the ["Static files" section](https://github.com/django-components/django-components/tree/master/sampleproject).
Migration steps: Migration steps:

View file

@ -5,9 +5,9 @@ weight: 5
## Community questions ## Community questions
The best place to ask questions is in our [Github Discussion board](https://github.com/EmilStenstrom/django-components/discussions). The best place to ask questions is in our [Github Discussion board](https://github.com/django-components/django-components/discussions).
Please, before opening a new discussion, [check if similar discussion wasn't opened already](https://github.com/EmilStenstrom/django-components/discussions?discussions_q=). Please, before opening a new discussion, [check if similar discussion wasn't opened already](https://github.com/django-components/django-components/discussions?discussions_q=).
## Community examples ## Community examples

View file

@ -23,5 +23,5 @@ so come aboard!
## Sponsoring ## Sponsoring
Another way you can get involved is by [donating](https://github.com/sponsors/EmilStenstrom) Another way you can get involved is by [donating](https://github.com/django-components/django-components)
to the development of django_components. to the development of django_components.

View file

@ -5,7 +5,7 @@ weight: 7
## Install locally and run the tests ## Install locally and run the tests
Start by forking the project by clicking the **Fork button** up in the right corner in the [GitHub](https://github.com/EmilStenstrom/django-components). Start by forking the project by clicking the **Fork button** up in the right corner in the [GitHub](https://github.com/django-components/django-components).
This makes a copy of the repository in your own name. Now you can clone this repository locally and start adding features: This makes a copy of the repository in your own name. Now you can clone this repository locally and start adding features:
```sh ```sh
@ -58,15 +58,15 @@ tox
How do you check that your changes to django-components project will work in an actual Django project? How do you check that your changes to django-components project will work in an actual Django project?
Use the [sampleproject](https://github.com/EmilStenstrom/django-components/tree/master/sampleproject/) demo project to validate the changes: Use the [sampleproject](https://github.com/django-components/django-components/tree/master/sampleproject/) demo project to validate the changes:
1. Navigate to [sampleproject](https://github.com/EmilStenstrom/django-components/tree/master/sampleproject/) directory: 1. Navigate to [sampleproject](https://github.com/django-components/django-components/tree/master/sampleproject/) directory:
```sh ```sh
cd sampleproject cd sampleproject
``` ```
2. Install dependencies from the [requirements.txt](https://github.com/EmilStenstrom/django-components/blob/master/sampleproject/requirements.txt) file: 2. Install dependencies from the [requirements.txt](https://github.com/django-components/django-components/blob/master/sampleproject/requirements.txt) file:
```sh ```sh
pip install -r requirements.txt pip install -r requirements.txt
@ -138,7 +138,7 @@ To publish the package to PyPI, use `twine` ([See Python user guide](https://pac
twine upload --repository pypi dist/* -u __token__ -p <PyPI_TOKEN> twine upload --repository pypi dist/* -u __token__ -p <PyPI_TOKEN>
``` ```
[See the full workflow here.](https://github.com/EmilStenstrom/django-components/discussions/557#discussioncomment-10179141) [See the full workflow here.](https://github.com/django-components/django-components/discussions/557#discussioncomment-10179141)
## Development guides ## Development guides

View file

@ -7,6 +7,8 @@ _It is strongly recommended to read this section before using django-components
## Static files ## Static files
**TL;DR: No action needed from v0.100 onwards. Before v0.100, use `safer_staticfiles` to avoid exposing backend logic.**
Components can be organized however you prefer. Components can be organized however you prefer.
That said, our prefered way is to keep the files of a component close together by bundling them in the same directory. That said, our prefered way is to keep the files of a component close together by bundling them in the same directory.
@ -68,6 +70,6 @@ python manage.py runserver
``` ```
For a step-by-step guide on deploying production server with static files, For a step-by-step guide on deploying production server with static files,
[see the demo project](https://github.com/EmilStenstrom/django-components/tree/master/sampleproject). [see the demo project](https://github.com/django-components/django-components/tree/master/sampleproject).
See the older versions of the sampleproject for a setup with pre-v0.100 version. See the older versions of the sampleproject for a setup with pre-v0.100 version.

View file

@ -3,9 +3,9 @@ title: Welcome to Django Components
weight: 1 weight: 1
--- ---
<img src="https://raw.githubusercontent.com/EmilStenstrom/django-components/master/logo/logo-black-on-white.svg" alt="django-components" style="max-width: 100%; background: white; color: black;"> <img src="https://raw.githubusercontent.com/django-components/django-components/master/logo/logo-black-on-white.svg" alt="django-components" style="max-width: 100%; background: white; color: black;">
[![PyPI - Version](https://img.shields.io/pypi/v/django-components)](https://pypi.org/project/django-components/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-components)](https://pypi.org/project/django-components/) [![PyPI - License](https://img.shields.io/pypi/l/django-components)](https://github.com/EmilStenstrom/django-components/blob/master/LICENSE/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/django-components)](https://pypistats.org/packages/django-components) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/EmilStenstrom/django-components/tests.yml)](https://github.com/EmilStenstrom/django-components/actions/workflows/tests.yml) [![PyPI - Version](https://img.shields.io/pypi/v/django-components)](https://pypi.org/project/django-components/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-components)](https://pypi.org/project/django-components/) [![PyPI - License](https://img.shields.io/pypi/l/django-components)](https://github.com/django-components/django-components/blob/master/LICENSE/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/django-components)](https://pypistats.org/packages/django-components) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/django-components/django-components/tests.yml)](https://github.com/django-components/django-components/actions/workflows/tests.yml)
django-components introduces component-based architecture to Django's server-side rendering. django-components introduces component-based architecture to Django's server-side rendering.
It combines Django's templating system with the modularity seen in modern frontend frameworks like Vue or React. It combines Django's templating system with the modularity seen in modern frontend frameworks like Vue or React.
@ -133,7 +133,7 @@ And this is what gets rendered:
Read on to learn about all the exciting details and configuration possibilities! Read on to learn about all the exciting details and configuration possibilities!
(If you instead prefer to jump right into the code, [check out the example project](https://github.com/EmilStenstrom/django-components/tree/master/sampleproject)) (If you instead prefer to jump right into the code, [check out the example project](https://github.com/django-components/django-components/tree/master/sampleproject))
## Release notes ## Release notes

View file

@ -18,7 +18,7 @@ usage: manage.py startcomponent [-h] [--path PATH] [--js JS] [--css CSS] [--temp
<a href="https://github.com/EmilStenstrom/django-components/tree/master/src/django_components/management/commands/startcomponent.py#L8" target="_blank">See source code</a> <a href="https://github.com/django-components/django-components/tree/master/src/django_components/management/commands/startcomponent.py#L8" target="_blank">See source code</a>
@ -132,7 +132,7 @@ usage: manage.py upgradecomponent [-h] [--path PATH] [--version] [-v {0,1,2,3}]
<a href="https://github.com/EmilStenstrom/django-components/tree/master/src/django_components/management/commands/upgradecomponent.py#L12" target="_blank">See source code</a> <a href="https://github.com/django-components/django-components/tree/master/src/django_components/management/commands/upgradecomponent.py#L12" target="_blank">See source code</a>

View file

@ -21,7 +21,7 @@ Import as
<a href="https://github.com/EmilStenstrom/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a> <a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
@ -128,7 +128,7 @@ can access only the data that was explicitly passed to it:
<a href="https://github.com/EmilStenstrom/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a> <a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
@ -151,7 +151,7 @@ If you insert this tag multiple times, ALL CSS links will be duplicately inserte
<a href="https://github.com/EmilStenstrom/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a> <a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
@ -175,7 +175,7 @@ If you insert this tag multiple times, ALL JS scripts will be duplicately insert
<a href="https://github.com/EmilStenstrom/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a> <a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
@ -273,7 +273,7 @@ use `{% fill %}` with `name` set to `"default"`:
<a href="https://github.com/EmilStenstrom/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a> <a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
@ -336,7 +336,7 @@ renders
<a href="https://github.com/EmilStenstrom/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a> <a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
@ -416,7 +416,7 @@ user = self.inject("user_data")["user"]
<a href="https://github.com/EmilStenstrom/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a> <a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>

View file

@ -52,7 +52,7 @@ def _format_source_code_html(relative_filepath: Path, lineno: Optional[int]):
branch_path = f"tree/{SOURCE_CODE_GIT_BRANCH}" branch_path = f"tree/{SOURCE_CODE_GIT_BRANCH}"
lineno_hash = f"#L{lineno}" if lineno is not None else "" lineno_hash = f"#L{lineno}" if lineno is not None else ""
# Generate URL pointing to the source file like # Generate URL pointing to the source file like
# https://github.com/EmilStenstrom/django-components/blob/master/src/django_components/components/dynamic.py#L8 # https://github.com/django-components/django-components/blob/master/src/django_components/components/dynamic.py#L8
url = f"{repo_url}/{branch_path}/{relative_filepath}{lineno_hash}" url = f"{repo_url}/{branch_path}/{relative_filepath}{lineno_hash}"
# Open in new tab # Open in new tab

View file

@ -1,11 +1,11 @@
--- ---
site_name: Django-Components site_name: Django-Components
site_description: A way to create simple reusable template components in Django. site_description: A way to create simple reusable template components in Django.
site_url: https://emilstenstrom.github.io/django-components/ site_url: https://django-components.github.io/django-components/
repo_url: https://github.com/EmilStenstrom/django-components repo_url: https://github.com/django-components/django-components
repo_name: EmilStenstrom/django-components repo_name: django-components/django-components
edit_uri: https://github.com/EmilStenstrom/django-components/edit/master/docs/ edit_uri: https://github.com/django-components/django-components/edit/master/docs/
dev_addr: "127.0.0.1:9000" dev_addr: "127.0.0.1:9000"
site_dir: site site_dir: site
@ -79,7 +79,7 @@ extra:
alias: true alias: true
social: social:
- icon: fontawesome/brands/github - icon: fontawesome/brands/github
link: https://github.com/EmilStenstrom/django-components link: https://github.com/django-components/django-components
- icon: fontawesome/brands/python - icon: fontawesome/brands/python
link: https://pypi.org/project/django-components/ link: https://pypi.org/project/django-components/
@ -94,7 +94,7 @@ markdown_extensions:
# mdx_truly_sane_lists: {} # mdx_truly_sane_lists: {}
pymdownx.magiclink: pymdownx.magiclink:
repo_url_shorthand: true repo_url_shorthand: true
user: EmilStenstrom user: django-components
repo: django-components repo: django-components
pymdownx.details: {} pymdownx.details: {}
pymdownx.highlight: pymdownx.highlight:

View file

@ -35,10 +35,10 @@ license = {text = "MIT"}
# See https://docs.pypi.org/project_metadata/#icons # See https://docs.pypi.org/project_metadata/#icons
[project.urls] [project.urls]
Homepage = "https://github.com/EmilStenstrom/django-components/" Homepage = "https://github.com/django-components/django-components/"
Documentation = "https://emilstenstrom.github.io/django-components/" Documentation = "https://django-components.github.io/django-components/"
Changelog = "https://emilstenstrom.github.io/django-components/latest/release_notes/" Changelog = "https://django-components.github.io/django-components/latest/release_notes/"
Issues = "https://github.com/EmilStenstrom/django-components/issues" Issues = "https://github.com/django-components/django-components/issues"
Donate = "https://github.com/sponsors/EmilStenstrom" Donate = "https://github.com/sponsors/EmilStenstrom"

View file

@ -236,7 +236,7 @@ class ComponentsSettings(NamedTuple):
> From v0.67 to v0.78 (incl) the default value was `"isolated"`. > From v0.67 to v0.78 (incl) the default value was `"isolated"`.
> >
> For v0.79 and later, the default is again `"django"`. See the rationale for change > For v0.79 and later, the default is again `"django"`. See the rationale for change
> [here](https://github.com/EmilStenstrom/django-components/issues/498). > [here](https://github.com/django-components/django-components/issues/498).
""" """
dynamic_component_name: Optional[str] = None dynamic_component_name: Optional[str] = None

View file

@ -21,7 +21,7 @@ class ComponentsConfig(AppConfig):
# NOTE: This monkeypatch is applied here, before Django processes any requests. # NOTE: This monkeypatch is applied here, before Django processes any requests.
# To make django-components work with django-debug-toolbar-template-profiler # To make django-components work with django-debug-toolbar-template-profiler
# See https://github.com/EmilStenstrom/django-components/discussions/819 # See https://github.com/django-components/django-components/discussions/819
monkeypatch_template_cls(Template) monkeypatch_template_cls(Template)
# Import modules set in `COMPONENTS.libraries` setting # Import modules set in `COMPONENTS.libraries` setting
@ -31,7 +31,7 @@ class ComponentsConfig(AppConfig):
autodiscover() autodiscover()
# Auto-reload Django dev server when any component files changes # Auto-reload Django dev server when any component files changes
# See https://github.com/EmilStenstrom/django-components/discussions/567#discussioncomment-10273632 # See https://github.com/django-components/django-components/discussions/567#discussioncomment-10273632
if app_settings.RELOAD_ON_FILE_CHANGE: if app_settings.RELOAD_ON_FILE_CHANGE:
_watch_component_files_for_autoreload() _watch_component_files_for_autoreload()
@ -56,7 +56,7 @@ class ComponentsConfig(AppConfig):
registry.register(app_settings.DYNAMIC_COMPONENT_NAME, DynamicComponent) registry.register(app_settings.DYNAMIC_COMPONENT_NAME, DynamicComponent)
# See https://github.com/EmilStenstrom/django-components/issues/586#issue-2472678136 # See https://github.com/django-components/django-components/issues/586#issue-2472678136
def _watch_component_files_for_autoreload() -> None: def _watch_component_files_for_autoreload() -> None:
from django_components.util.loader import get_component_dirs from django_components.util.loader import get_component_dirs

View file

@ -981,12 +981,12 @@ class Component(
# Allow to provide a dict instead of Context # Allow to provide a dict instead of Context
# NOTE: This if/else is important to avoid nested Contexts, # NOTE: This if/else is important to avoid nested Contexts,
# See https://github.com/EmilStenstrom/django-components/issues/414 # See https://github.com/django-components/django-components/issues/414
if not isinstance(context, Context): if not isinstance(context, Context):
context = RequestContext(request, context) if request else Context(context) context = RequestContext(request, context) if request else Context(context)
# Required for compatibility with Django's {% extends %} tag # Required for compatibility with Django's {% extends %} tag
# See https://github.com/EmilStenstrom/django-components/pull/859 # See https://github.com/django-components/django-components/pull/859
context.render_context.push({BLOCK_CONTEXT_KEY: context.render_context.get(BLOCK_CONTEXT_KEY, {})}) context.render_context.push({BLOCK_CONTEXT_KEY: context.render_context.get(BLOCK_CONTEXT_KEY, {})})
# By adding the current input to the stack, we temporarily allow users # By adding the current input to the stack, we temporarily allow users
@ -1045,7 +1045,7 @@ class Component(
_COMPONENT_SLOT_CTX_CONTEXT_KEY: component_slot_ctx, _COMPONENT_SLOT_CTX_CONTEXT_KEY: component_slot_ctx,
_REGISTRY_CONTEXT_KEY: self.registry, _REGISTRY_CONTEXT_KEY: self.registry,
# NOTE: Public API for variables accessible from within a component's template # NOTE: Public API for variables accessible from within a component's template
# See https://github.com/EmilStenstrom/django-components/issues/280#issuecomment-2081180940 # See https://github.com/django-components/django-components/issues/280#issuecomment-2081180940
"component_vars": ComponentVars( "component_vars": ComponentVars(
is_filled=is_filled, is_filled=is_filled,
), ),
@ -1400,8 +1400,8 @@ def _prepare_template(
with context.update(context_data): with context.update(context_data):
# Associate the newly-created Context with a Template, otherwise we get # Associate the newly-created Context with a Template, otherwise we get
# an error when we try to use `{% include %}` tag inside the template? # an error when we try to use `{% include %}` tag inside the template?
# See https://github.com/EmilStenstrom/django-components/issues/580 # See https://github.com/django-components/django-components/issues/580
# And https://github.com/EmilStenstrom/django-components/issues/634 # And https://github.com/django-components/django-components/issues/634
template = component._get_template(context) template = component._get_template(context)
if not is_template_cls_patched(template): if not is_template_cls_patched(template):
@ -1414,7 +1414,7 @@ def _prepare_template(
# Set `Template._djc_is_component_nested` based on whether we're currently INSIDE # Set `Template._djc_is_component_nested` based on whether we're currently INSIDE
# the `{% extends %}` tag. # the `{% extends %}` tag.
# Part of fix for https://github.com/EmilStenstrom/django-components/issues/508 # Part of fix for https://github.com/django-components/django-components/issues/508
# See django_monkeypatch.py # See django_monkeypatch.py
template._djc_is_component_nested = bool(context.render_context.get(BLOCK_CONTEXT_KEY)) template._djc_is_component_nested = bool(context.render_context.get(BLOCK_CONTEXT_KEY))

View file

@ -738,7 +738,7 @@ def _resolve_component_relative_files(
if isinstance(filepath, str): if isinstance(filepath, str):
filepath_abs = os.path.join(comp_dir_abs, filepath) filepath_abs = os.path.join(comp_dir_abs, filepath)
# NOTE: The paths to resources need to use POSIX (forward slashes) for Django to wor # NOTE: The paths to resources need to use POSIX (forward slashes) for Django to wor
# See https://github.com/EmilStenstrom/django-components/issues/796 # See https://github.com/django-components/django-components/issues/796
filepath_rel_to_comp_dir = Path(os.path.join(comp_dir_rel, filepath)).as_posix() filepath_rel_to_comp_dir = Path(os.path.join(comp_dir_rel, filepath)).as_posix()
if os.path.isfile(filepath_abs): if os.path.isfile(filepath_abs):

View file

@ -23,7 +23,7 @@ def make_isolated_context_copy(context: Context) -> Context:
copy_forloop_context(context, context_copy) copy_forloop_context(context, context_copy)
# Required for compatibility with Django's {% extends %} tag # Required for compatibility with Django's {% extends %} tag
# See https://github.com/EmilStenstrom/django-components/pull/859 # See https://github.com/django-components/django-components/pull/859
context_copy.render_context = context.render_context context_copy.render_context = context.render_context
# Pass through our internal keys # Pass through our internal keys

View file

@ -135,7 +135,7 @@ class NodeMeta(type):
# # {'data-id': 1} # # {'data-id': 1}
# ``` # ```
# #
# See https://github.com/EmilStenstrom/django-components/discussions/900#discussioncomment-11859970 # See https://github.com/django-components/django-components/discussions/900#discussioncomment-11859970
resolved_params_without_invalid_kwargs = [] resolved_params_without_invalid_kwargs = []
invalid_kwargs = {} invalid_kwargs = {}
did_see_special_kwarg = False did_see_special_kwarg = False

View file

@ -436,7 +436,7 @@ class SlotNode(BaseNode):
# Required for compatibility with Django's {% extends %} tag # Required for compatibility with Django's {% extends %} tag
# This makes sure that the render context used outside of a component # This makes sure that the render context used outside of a component
# is the same as the one used inside the slot. # is the same as the one used inside the slot.
# See https://github.com/EmilStenstrom/django-components/pull/859 # See https://github.com/django-components/django-components/pull/859
render_ctx_layer = used_ctx.render_context.dicts[-2] if len(used_ctx.render_context.dicts) > 1 else {} render_ctx_layer = used_ctx.render_context.dicts[-2] if len(used_ctx.render_context.dicts) > 1 else {}
with used_ctx.render_context.push(render_ctx_layer): with used_ctx.render_context.push(render_ctx_layer):
# Render slot as a function # Render slot as a function

View file

@ -60,7 +60,7 @@ def monkeypatch_template_render(template_cls: Type[Template]) -> None:
# Modify `Template.render` to set `isolated_context` kwarg of `push_state` # Modify `Template.render` to set `isolated_context` kwarg of `push_state`
# based on our custom `Template._djc_is_component_nested`. # based on our custom `Template._djc_is_component_nested`.
# #
# Part of fix for https://github.com/EmilStenstrom/django-components/issues/508 # Part of fix for https://github.com/django-components/django-components/issues/508
# #
# NOTE 1: While we could've subclassed Template, then we would need to either # NOTE 1: While we could've subclassed Template, then we would need to either
# 1) ask the user to change the backend, so all templates are of our subclass, or # 1) ask the user to change the backend, so all templates are of our subclass, or

View file

@ -184,7 +184,7 @@ def get_component_files(suffix: Optional[str] = None) -> List[ComponentFileEntry
# For for apps, the directories may be outside of the project, e.g. in case of third party # For for apps, the directories may be outside of the project, e.g. in case of third party
# apps. So we have to resolve the python import path relative to the package name / the root # apps. So we have to resolve the python import path relative to the package name / the root
# import path for the app. # import path for the app.
# See https://github.com/EmilStenstrom/django-components/issues/669 # See https://github.com/django-components/django-components/issues/669
for conf in apps.get_app_configs(): for conf in apps.get_app_configs():
for app_dir in app_settings.APP_DIRS: for app_dir in app_settings.APP_DIRS:
comps_path = Path(conf.path).joinpath(app_dir) comps_path = Path(conf.path).joinpath(app_dir)

View file

@ -16,7 +16,7 @@ from django_components.expression import process_aggregate_kwargs
from django_components.util.tag_parser import TagAttr, parse_tag from django_components.util.tag_parser import TagAttr, parse_tag
# For details see https://github.com/EmilStenstrom/django-components/pull/902#discussion_r1913611633 # For details see https://github.com/django-components/django-components/pull/902#discussion_r1913611633
# and following comments # and following comments
def validate_params( def validate_params(
tag: str, tag: str,

View file

@ -6,7 +6,7 @@ from django.utils.html import format_html, html_safe
from django_components import Component, register from django_components import Component, register
# Format as mentioned in https://github.com/EmilStenstrom/django-components/issues/522#issuecomment-2173577094 # Format as mentioned in https://github.com/django-components/django-components/issues/522#issuecomment-2173577094
@html_safe @html_safe
class PathObj: class PathObj:
def __init__(self, static_path: str) -> None: def __init__(self, static_path: str) -> None:

View file

@ -1019,8 +1019,8 @@ class ComponentRenderTest(BaseTestCase):
""", """,
) )
# See https://github.com/EmilStenstrom/django-components/issues/580 # See https://github.com/django-components/django-components/issues/580
# And https://github.com/EmilStenstrom/django-components/commit/fee26ec1d8b46b5ee065ca1ce6143889b0f96764 # And https://github.com/django-components/django-components/commit/fee26ec1d8b46b5ee065ca1ce6143889b0f96764
@parametrize_context_behavior(["django", "isolated"]) @parametrize_context_behavior(["django", "isolated"])
def test_render_with_include_and_context(self): def test_render_with_include_and_context(self):
class SimpleComponent(Component): class SimpleComponent(Component):
@ -1041,9 +1041,9 @@ class ComponentRenderTest(BaseTestCase):
""", """,
) )
# See https://github.com/EmilStenstrom/django-components/issues/580 # See https://github.com/django-components/django-components/issues/580
# And https://github.com/EmilStenstrom/django-components/issues/634 # And https://github.com/django-components/django-components/issues/634
# And https://github.com/EmilStenstrom/django-components/commit/fee26ec1d8b46b5ee065ca1ce6143889b0f96764 # And https://github.com/django-components/django-components/commit/fee26ec1d8b46b5ee065ca1ce6143889b0f96764
@parametrize_context_behavior(["django", "isolated"]) @parametrize_context_behavior(["django", "isolated"])
def test_render_with_include_and_request_context(self): def test_render_with_include_and_request_context(self):
class SimpleComponent(Component): class SimpleComponent(Component):
@ -1064,8 +1064,8 @@ class ComponentRenderTest(BaseTestCase):
""", """,
) )
# See https://github.com/EmilStenstrom/django-components/issues/580 # See https://github.com/django-components/django-components/issues/580
# And https://github.com/EmilStenstrom/django-components/issues/634 # And https://github.com/django-components/django-components/issues/634
@parametrize_context_behavior(["django", "isolated"]) @parametrize_context_behavior(["django", "isolated"])
def test_request_context_is_populated_from_context_processors(self): def test_request_context_is_populated_from_context_processors(self):
@register("thing") @register("thing")

View file

@ -477,7 +477,7 @@ class MediaPathAsObjectTests(BaseTestCase):
def __str__(self): def __str__(self):
return f'<link css_tag href="{self.path}" rel="stylesheet" />' return f'<link css_tag href="{self.path}" rel="stylesheet" />'
# Format as mentioned in https://github.com/EmilStenstrom/django-components/issues/522#issuecomment-2173577094 # Format as mentioned in https://github.com/django-components/django-components/issues/522#issuecomment-2173577094
@html_safe @html_safe
class PathObj: class PathObj:
def __init__(self, static_path: str) -> None: def __init__(self, static_path: str) -> None:
@ -731,7 +731,7 @@ class MediaPathAsObjectTests(BaseTestCase):
class MediaStaticfilesTests(BaseTestCase): class MediaStaticfilesTests(BaseTestCase):
# For context see https://github.com/EmilStenstrom/django-components/issues/522 # For context see https://github.com/django-components/django-components/issues/522
@override_settings( @override_settings(
# Configure static files. The dummy files are set up in the `./static_root` dir. # Configure static files. The dummy files are set up in the `./static_root` dir.
# The URL should have path prefix /static/. # The URL should have path prefix /static/.
@ -777,7 +777,7 @@ class MediaStaticfilesTests(BaseTestCase):
self.assertInHTML('<script defer src="/static/calendar/script.js"></script>', rendered) self.assertInHTML('<script defer src="/static/calendar/script.js"></script>', rendered)
# For context see https://github.com/EmilStenstrom/django-components/issues/522 # For context see https://github.com/django-components/django-components/issues/522
@override_settings( @override_settings(
# Configure static files. The dummy files are set up in the `./static_root` dir. # Configure static files. The dummy files are set up in the `./static_root` dir.
# The URL should have path prefix /static/. # The URL should have path prefix /static/.
@ -972,7 +972,7 @@ class MediaRelativePathTests(BaseTestCase):
then we force to call `static`. And if this happens during `collectstatic` run, then we force to call `static`. And if this happens during `collectstatic` run,
then this triggers an error, because `static` is called before the static files exist. then this triggers an error, because `static` is called before the static files exist.
https://github.com/EmilStenstrom/django-components/issues/522#issuecomment-2173577094 https://github.com/django-components/django-components/issues/522#issuecomment-2173577094
""" """
# Ensure that the module is executed again after import in autodiscovery # Ensure that the module is executed again after import in autodiscovery

View file

@ -61,7 +61,7 @@ class NestedTagsTests(BaseTestCase):
"var": var, "var": var,
} }
# See https://github.com/EmilStenstrom/django-components/discussions/671 # See https://github.com/django-components/django-components/discussions/671
@parametrize_context_behavior(["django", "isolated"]) @parametrize_context_behavior(["django", "isolated"])
def test_nested_tags(self): def test_nested_tags(self):
registry.register("test", self.SimpleComponent) registry.register("test", self.SimpleComponent)

View file

@ -746,7 +746,7 @@ class InjectTest(BaseTestCase):
with self.assertRaises(RuntimeError): with self.assertRaises(RuntimeError):
comp.inject("abc", "def") comp.inject("abc", "def")
# See https://github.com/EmilStenstrom/django-components/pull/778 # See https://github.com/django-components/django-components/pull/778
@parametrize_context_behavior(["django", "isolated"]) @parametrize_context_behavior(["django", "isolated"])
def test_inject_in_fill(self): def test_inject_in_fill(self):
@register("injectee") @register("injectee")
@ -814,7 +814,7 @@ class InjectTest(BaseTestCase):
""", """,
) )
# See https://github.com/EmilStenstrom/django-components/pull/786 # See https://github.com/django-components/django-components/pull/786
@parametrize_context_behavior(["django", "isolated"]) @parametrize_context_behavior(["django", "isolated"])
def test_inject_in_slot_in_fill(self): def test_inject_in_slot_in_fill(self):
@register("injectee") @register("injectee")

View file

@ -1112,7 +1112,7 @@ class PassthroughSlotsTest(BaseTestCase):
self.assertHTMLEqual(rendered, expected) self.assertHTMLEqual(rendered, expected)
# See https://github.com/EmilStenstrom/django-components/issues/698 # See https://github.com/django-components/django-components/issues/698
class NestedSlotsTests(BaseTestCase): class NestedSlotsTests(BaseTestCase):
class NestedSlots(Component): class NestedSlots(Component):
template: types.django_html = """ template: types.django_html = """