mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 15:39:08 +00:00
chore: working docs
This commit is contained in:
parent
295ea95d1b
commit
95400944ec
22 changed files with 158 additions and 84 deletions
|
@ -1,10 +1,12 @@
|
|||
# Release notes
|
||||
|
||||
🚨📢 **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.
|
||||
🚨📢 **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.
|
||||
|
||||
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.
|
||||
|
||||
**Version 0.34** adds components as views, which allows you to handle requests and render responses from within a component. See the [documentation](#components-as-views) for more details.
|
||||
**Version 0.34** adds components as views, which allows you to handle requests and render responses from within a component. See the [documentation](user_guide/creating_using_components/using_slots.md#components-as-views) for more details.
|
||||
|
||||
**Version 0.28** introduces 'implicit' slot filling and the `default` option for `slot` tags.
|
||||
|
||||
|
|
8
docs/SUMMARY.md
Normal file
8
docs/SUMMARY.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
* [Home](index.md)
|
||||
* [Changelog](changelog.md)
|
||||
* [Code of Conduct](code_of_conduct.md)
|
||||
* [License](license.md)
|
||||
* [Usage](user_guide/)
|
||||
* [Developer Guide](dev_guide/index.md)
|
||||
* Reference
|
||||
* [API Reference](reference/)
|
|
@ -30,13 +30,12 @@ pytest
|
|||
The library is also tested across many versions of Python and Django. To run tests that way:
|
||||
|
||||
```bash
|
||||
pyenv install -s 3.7
|
||||
pyenv install -s 3.8
|
||||
pyenv install -s 3.9
|
||||
pyenv install -s 3.10
|
||||
pyenv install -s 3.11
|
||||
pyenv install -s 3.12
|
||||
pyenv local 3.6 3.7 3.8 3.9 3.10 3.11 3.12
|
||||
pyenv local 3.8 3.9 3.10 3.11 3.12
|
||||
tox -p
|
||||
```
|
||||
|
||||
|
|
|
@ -1 +1,47 @@
|
|||
--8<-- "README.md"
|
||||
# django-components
|
||||
|
||||
[](https://pypi.org/project/django-components/) [](https://pypi.org/project/django-components/) [](https://EmilStenstrom.github.io/django-components/latest/license/) [](https://pypistats.org/packages/django-components) [](https://github.com/EmilStenstrom/django-components/actions/workflows/tests.yml)
|
||||
|
||||
Create simple reusable template components in Django
|
||||
|
||||
## Features
|
||||
|
||||
- ✨ **Reusable components**: [Create components](user_guide/creating_using_components/create_first_component.md) that can be reused in different parts of your project, or even in different projects.
|
||||
- 📁 **Single file components**: [Keep your Python, CSS, Javascript and HTML in one place](user_guide/creating_using_components/single_file_component.md) (if you wish)
|
||||
- 🎰 **Slots**: Define [slots](user_guide/creating_using_components/using_slots.md) in your components to make them more flexible.
|
||||
- 💻 **CLI**: A [command line interface](user_guide/commands.md) to help you create new components.
|
||||
- 🚀 **Wide compatibility**: Works with [modern and LTS versions of Django](user_guide/installation/requirements_compatibility.md).
|
||||
- **Load assets**: Automatically load the right CSS and Javascript files for your components, with [our middleware](user_guide/creating_using_components/middleware.md).
|
||||
|
||||
|
||||
## Summary
|
||||
|
||||
It lets you create "template components", that contains both the template, the Javascript and the CSS needed to generate the front end code you need for a modern app. Use components like this:
|
||||
|
||||
```htmldjango
|
||||
{% component "calendar" date="2015-06-19" %}{% endcomponent %}
|
||||
```
|
||||
|
||||
And this is what gets rendered (plus the CSS and Javascript you've specified):
|
||||
|
||||
```html
|
||||
<div class="calendar-component">Today's date is <span>2015-06-19</span></div>
|
||||
```
|
||||
|
||||
Read our [user guide](user_guide/index.md) to set it up and learn about the details!
|
||||
|
||||
## Compatibility
|
||||
|
||||
`django-components` is compatible with modern and LTS versions of Django.
|
||||
|
||||
Check out the [compatibility guide](user_guide/installation/requirements_compatibility.md) to see which versions are supported.
|
||||
|
||||
## Community examples
|
||||
|
||||
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.
|
||||
|
||||
- [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/).
|
||||
|
||||
## License
|
||||
|
||||
`django-components` is licensed under the MIT license. See the [LICENSE](license.md) file for more details.
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# License
|
||||
|
||||
```
|
||||
--8<-- "LICENSE"
|
||||
```
|
||||
|
|
16
docs/user_guide/SUMMARY.md
Normal file
16
docs/user_guide/SUMMARY.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
* [Getting Started](index.md)
|
||||
* [Installation](installation/index.md)
|
||||
* [Compatibility & Requirements](installation/requirements_compatibility.md)
|
||||
* Creating & Using Components
|
||||
* [Creating Your First Component](creating_using_components/create_first_component.md)
|
||||
* [Using Components](creating_using_components/use_component.md)
|
||||
* [Single File Components](creating_using_components/single_file_component.md)
|
||||
* [Context Scope](creating_using_components/context_scope.md)
|
||||
* [Using Slots](creating_using_components/using_slots.md)
|
||||
* [Advanced Component Usage](creating_using_components/advanced.md)
|
||||
* Integration with your Django project
|
||||
* [Security](integration/security.md)
|
||||
* [Middleware](integration/middleware.md)
|
||||
* [Settings](integration/settings.md)
|
||||
* [CLI Commands](integration/commands.md)
|
||||
* [Logging and Debugging](integration/logging_debugging.md)
|
|
@ -127,6 +127,8 @@ This is fine too:
|
|||
|
||||
## Components as views
|
||||
|
||||
|
||||
<!-- md:version 0.34 -->
|
||||
_New in version 0.34_
|
||||
|
||||
Components can now be used as views. To do this, [`Component`][django_components.component.Component] subclasses Django's [`View`][] class. This means that you can use all of the [methods](https://docs.djangoproject.com/en/5.0/ref/class-based-views/base/#view) of `View` in your component. For example, you can override `get` and `post` to handle GET and POST requests, respectively.
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
[TOC]
|
||||
# Getting started
|
||||
|
||||
## Summary
|
||||
|
||||
--8<-- "docs/user_guide/SUMMARY.md:2"
|
||||
|
|
|
@ -2,9 +2,25 @@
|
|||
|
||||
Install the app into your environment:
|
||||
|
||||
> ```pip install django-components```
|
||||
=== "pip"
|
||||
|
||||
Then add the app into [`INSTALLED_APPS`][INSTALLED_APPS] in settings.py
|
||||
```bash
|
||||
pip install django-components
|
||||
```
|
||||
|
||||
=== "poetry"
|
||||
|
||||
```bash
|
||||
poetry add django-components
|
||||
```
|
||||
|
||||
=== "pdm"
|
||||
|
||||
```bash
|
||||
pdm add django-components
|
||||
```
|
||||
|
||||
Then add the app into [`INSTALLED_APPS`][INSTALLED_APPS] in your settings module (e.g. `settings.py`)
|
||||
|
||||
```python
|
||||
INSTALLED_APPS = [
|
||||
|
@ -13,7 +29,7 @@ INSTALLED_APPS = [
|
|||
]
|
||||
```
|
||||
|
||||
Modify [`TEMPLATES`][TEMPLATES] section of settings.py as follows:
|
||||
Modify [`TEMPLATES`][TEMPLATES] section of your settings module as follows:
|
||||
|
||||
|
||||
- *Remove `'APP_DIRS': True,`*
|
Loading…
Add table
Add a link
Reference in a new issue