app_settings ¤
ContextBehavior ¤
DJANGO class-attribute
instance-attribute
¤
With this setting, component fills behave as usual Django tags. That is, they enrich the context, and pass it along.
- Component fills use the context of the component they are within.
- Variables from
get_context_data
are available to the component fill.
Example:
Given this template
{% with cheese="feta" %}
{% component 'my_comp' %}
{{ my_var }} # my_var
{{ cheese }} # cheese
{% endcomponent %}
{% endwith %}
and this context returned from the get_context_data()
method
Then if component "my_comp" defines context
Then this will render:
Because "my_comp" overrides the variable "my_var", so {{ my_var }}
equals 456
.
And variable "cheese" will equal feta
, because the fill CAN access the current context.
ISOLATED class-attribute
instance-attribute
¤
This setting makes the component fills behave similar to Vue or React, where the fills use EXCLUSIVELY the context variables defined in get_context_data
.
Example:
Given this template
{% with cheese="feta" %}
{% component 'my_comp' %}
{{ my_var }} # my_var
{{ cheese }} # cheese
{% endcomponent %}
{% endwith %}
and this context returned from the get_context_data()
method
Then if component "my_comp" defines context
Then this will render:
Because both variables "my_var" and "cheese" are taken from the root context. Since "cheese" is not defined in root context, it's empty.