mirror of
https://github.com/django-components/django-components.git
synced 2025-08-31 11:17:21 +00:00
refactor: remove middleware, add strategy "raw", and call render_deps() from within Template.render() (#1166)
* refactor: remove middleware, add strategy "raw", and call render_deps() from within Template.render() * refactor: fix formatting * refactor: fix benchmark tests * refactor: avoid processing deps if rendered HTML contains no components * refactor: remove comments * refactor: rename "raw" to "ignore"
This commit is contained in:
parent
1049c08324
commit
6253042e9e
37 changed files with 771 additions and 657 deletions
|
@ -156,15 +156,17 @@ This is how we achieve that:
|
|||
|
||||
There's multiple ways to achieve this:
|
||||
|
||||
- The approach recommended to the users is to use the `ComponentDependencyMiddleware` middleware, which scans all outgoing HTML, and post-processes the `<!-- _RENDERED -->` comments.
|
||||
|
||||
- If users are using `Component.render()` or `Component.render_to_response()`, these post-process the `<!-- _RENDERED -->` comments by default.
|
||||
|
||||
- NOTE: Users are able to opt out of the post-processing by setting `render_dependencies=False`.
|
||||
- NOTE: Users are able to opt out of the post-processing by setting `deps_strategy="ignore"`.
|
||||
|
||||
- For advanced use cases, users may use `render_dependencies()` directly. This is the function that both `ComponentDependencyMiddleware` and `Component.render()` call internally.
|
||||
- If one renders a Template directly, the `<!-- _RENDERED -->` will be processed too. We achieve this by
|
||||
modifying Django's `Template.render()` method.
|
||||
|
||||
`render_dependencies()`, whether called directly, via middleware or other way, does the following:
|
||||
- For advanced use cases, users may use `render_dependencies()` directly. This is the function that
|
||||
`Component.render()` calls internally.
|
||||
|
||||
`render_dependencies()`, whether called directly, or other way, does the following:
|
||||
|
||||
1. Find all `<!-- _RENDERED -->` comments, and for each comment:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue