mirror of
https://github.com/django-components/django-components.git
synced 2025-09-25 06:59:10 +00:00
chore: init docs
This commit is contained in:
parent
899b9a2738
commit
163b0941c2
49 changed files with 1447 additions and 9 deletions
13
docs/user_guide/creating_using_components/context_scope.md
Normal file
13
docs/user_guide/creating_using_components/context_scope.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Component context and scope
|
||||
|
||||
By default, components can access context variables from the parent template, just like templates that are included with the `{% include %}` tag. Just like with `{% include %}`, if you don't want the component template to have access to the parent context, add `only` to the end of the `{% component %}` tag):
|
||||
|
||||
```htmldjango
|
||||
{% component "calendar" date="2015-06-19" only %}{% endcomponent %}
|
||||
```
|
||||
|
||||
NOTE: `{% csrf_token %}` tags need access to the top-level context, and they will not function properly if they are rendered in a component that is called with the `only` modifier.
|
||||
|
||||
Components can also access the outer context in their context methods by accessing the property `outer_context`.
|
||||
|
||||
You can also set `context_behavior` to `isolated` to make all components isolated by default. This is useful if you want to make sure that components don't accidentally access the outer context.
|
Loading…
Add table
Add a link
Reference in a new issue