diff --git a/dev/getting_started/components_in_templates/index.html b/dev/getting_started/components_in_templates/index.html index 48b8a4a2..2352b527 100644 --- a/dev/getting_started/components_in_templates/index.html +++ b/dev/getting_started/components_in_templates/index.html @@ -20,7 +20,7 @@ return { "date": "1970-01-01", } -

This will register the component to the default registry. Default registry is loaded into the template by calling {% load component_tags %} inside the template.

Info

Why do we have to register components?

We want to use our component as a template tag ({% ... %}) in Django template.

In Django, template tags are managed by the Library instances. Whenever you include {% load xxx %} in your template, you are loading a Library instance into your template.

ComponentRegistry acts like a router and connects the registered components with the associated Library.

That way, when you include {% load component_tags %} in your template, you are able to "call" components like {% component "calendar" / %}.

ComponentRegistries also make it possible to group and share components as standalone packages. Learn more here.

Note

You can create custom ComponentRegistry instances, which will use different Library instances. In that case you will have to load different libraries depending on which components you want to use:

Example 1 - Using component defined in the default registry

{% load component_tags %}
+

This will register the component to the default registry. Default registry is loaded into the template by calling {% load component_tags %} inside the template.

Info

Why do we have to register components?

We want to use our component as a template tag ({% ... %}) in Django template.

In Django, template tags are managed by the Library instances. Whenever you include {% load xxx %} in your template, you are loading a Library instance into your template.

ComponentRegistry acts like a router and connects the registered components with the associated Library.

That way, when you include {% load component_tags %} in your template, you are able to "call" components like {% component "calendar" / %}.

ComponentRegistries also make it possible to group and share components as standalone packages. Learn more here.

Note

You can create custom ComponentRegistry instances, which will use different Library instances. In that case you will have to load different libraries depending on which components you want to use:

Example 1 - Using component defined in the default registry

{% load component_tags %}
 <div>
   {% component "calendar" / %}
 </div>
@@ -77,4 +77,4 @@
         import myapp.components.calendar
         import myapp.components.table
         ...
-

You can now render the components in templates!


Currently our component always renders the same content. Let's parametrise it, so that our Calendar component is configurable from within the template ➡️

\ No newline at end of file +

You can now render the components in templates!


Currently our component always renders the same content. Let's parametrise it, so that our Calendar component is configurable from within the template ➡️

\ No newline at end of file diff --git a/versions.json b/versions.json index 829958d6..ba99406c 100644 --- a/versions.json +++ b/versions.json @@ -1,7 +1,7 @@ [ { "version": "dev", - "title": "dev (9a4f835)", + "title": "dev (df7f94c)", "aliases": [] }, {