diff --git a/dev/reference/api/index.html b/dev/reference/api/index.html index b2d2b574..68dc72c2 100644 --- a/dev/reference/api/index.html +++ b/dev/reference/api/index.html @@ -123,11 +123,11 @@ return {"name": "World"}

template_name instance-attribute ¤

template_name: Optional[str]
 

See source code

Alias for template_file.

For historical reasons, django-components used template_name to align with Django's TemplateView.

template_file was introduced to align with js/js_file and css/css_file.

Setting and accessing this attribute is proxied to template_file.

as_view classmethod ¤

as_view(**initkwargs: Any) -> ViewFn
-

See source code

Shortcut for calling Component.View.as_view and passing component instance to it.

get_context_data ¤

get_context_data(*args: Any, **kwargs: Any) -> DataType
+

See source code

Shortcut for calling Component.View.as_view and passing component instance to it.

get_context_data ¤

get_context_data(*args: Any, **kwargs: Any) -> DataType
 

get_template ¤

get_template(context: Context) -> Optional[Union[str, Template]]
 

See source code

Inlined Django template associated with this component. Can be a plain string or a Template instance.

Only one of template_file, get_template_name, template or get_template must be defined.

get_template_name ¤

get_template_name(context: Context) -> Optional[str]
 

See source code

Filepath to the Django template associated with this component.

The filepath must be relative to either the file where the component class was defined, or one of the roots of STATIFILES_DIRS.

Only one of template_file, get_template_name, template or get_template must be defined.

inject ¤

inject(key: str, default: Optional[Any] = None) -> Any
-

See source code

Use this method to retrieve the data that was passed to a {% provide %} tag with the corresponding key.

To retrieve the data, inject() must be called inside a component that's inside the {% provide %} tag.

You may also pass a default that will be used if the provide tag with given key was NOT found.

This method mut be used inside the get_context_data() method and raises an error if called elsewhere.

Example:

Given this template:

{% provide "provider" hello="world" %}
+

See source code

Use this method to retrieve the data that was passed to a {% provide %} tag with the corresponding key.

To retrieve the data, inject() must be called inside a component that's inside the {% provide %} tag.

You may also pass a default that will be used if the provide tag with given key was NOT found.

This method mut be used inside the get_context_data() method and raises an error if called elsewhere.

Example:

Given this template:

{% provide "provider" hello="world" %}
     {% component "my_comp" %}
     {% endcomponent %}
 {% endprovide %}
@@ -152,7 +152,7 @@
     render_dependencies: bool = True,
     request: Optional[HttpRequest] = None,
 ) -> str
-

See source code

Render the component into a string.

Inputs: - args - Positional args for the component. This is the same as calling the component as {% component "my_comp" arg1 arg2 ... %} - kwargs - Kwargs for the component. This is the same as calling the component as {% component "my_comp" key1=val1 key2=val2 ... %} - slots - Component slot fills. This is the same as pasing {% fill %} tags to the component. Accepts a dictionary of { slot_name: slot_content } where slot_content can be a string or render function. - escape_slots_content - Whether the content from slots should be escaped. - context - A context (dictionary or Django's Context) within which the component is rendered. The keys on the context can be accessed from within the template. - NOTE: In "isolated" mode, context is NOT accessible, and data MUST be passed via component's args and kwargs. - type - Configure how to handle JS and CSS dependencies. - "document" (default) - JS dependencies are inserted into {% component_js_dependencies %}, or to the end of the <body> tag. CSS dependencies are inserted into {% component_css_dependencies %}, or the end of the <head> tag. - render_dependencies - Set this to False if you want to insert the resulting HTML into another component. - request - The request object. This is only required when needing to use RequestContext, e.g. to enable template context_processors. Unused if context is already an instance of Context Example:

MyComponent.render(
+

See source code

Render the component into a string.

Inputs: - args - Positional args for the component. This is the same as calling the component as {% component "my_comp" arg1 arg2 ... %} - kwargs - Kwargs for the component. This is the same as calling the component as {% component "my_comp" key1=val1 key2=val2 ... %} - slots - Component slot fills. This is the same as pasing {% fill %} tags to the component. Accepts a dictionary of { slot_name: slot_content } where slot_content can be a string or render function. - escape_slots_content - Whether the content from slots should be escaped. - context - A context (dictionary or Django's Context) within which the component is rendered. The keys on the context can be accessed from within the template. - NOTE: In "isolated" mode, context is NOT accessible, and data MUST be passed via component's args and kwargs. - type - Configure how to handle JS and CSS dependencies. - "document" (default) - JS dependencies are inserted into {% component_js_dependencies %}, or to the end of the <body> tag. CSS dependencies are inserted into {% component_css_dependencies %}, or the end of the <head> tag. - render_dependencies - Set this to False if you want to insert the resulting HTML into another component. - request - The request object. This is only required when needing to use RequestContext, e.g. to enable template context_processors. Unused if context is already an instance of Context Example:

MyComponent.render(
     args=[1, "two", {}],
     kwargs={
         "key": 123,
@@ -174,7 +174,7 @@
     *response_args: Any,
     **response_kwargs: Any
 ) -> HttpResponse
-

See source code

Render the component and wrap the content in the response class.

The response class is taken from Component.response_class. Defaults to django.http.HttpResponse.

This is the interface for the django.views.View class which allows us to use components as Django views with component.as_view().

Inputs: - args - Positional args for the component. This is the same as calling the component as {% component "my_comp" arg1 arg2 ... %} - kwargs - Kwargs for the component. This is the same as calling the component as {% component "my_comp" key1=val1 key2=val2 ... %} - slots - Component slot fills. This is the same as pasing {% fill %} tags to the component. Accepts a dictionary of { slot_name: slot_content } where slot_content can be a string or render function. - escape_slots_content - Whether the content from slots should be escaped. - context - A context (dictionary or Django's Context) within which the component is rendered. The keys on the context can be accessed from within the template. - NOTE: In "isolated" mode, context is NOT accessible, and data MUST be passed via component's args and kwargs. - type - Configure how to handle JS and CSS dependencies. - "document" (default) - JS dependencies are inserted into {% component_js_dependencies %}, or to the end of the <body> tag. CSS dependencies are inserted into {% component_css_dependencies %}, or the end of the <head> tag. - request - The request object. This is only required when needing to use RequestContext, e.g. to enable template context_processors. Unused if context is already an instance of Context

Any additional args and kwargs are passed to the response_class.

Example:

MyComponent.render_to_response(
+

See source code

Render the component and wrap the content in the response class.

The response class is taken from Component.response_class. Defaults to django.http.HttpResponse.

This is the interface for the django.views.View class which allows us to use components as Django views with component.as_view().

Inputs: - args - Positional args for the component. This is the same as calling the component as {% component "my_comp" arg1 arg2 ... %} - kwargs - Kwargs for the component. This is the same as calling the component as {% component "my_comp" key1=val1 key2=val2 ... %} - slots - Component slot fills. This is the same as pasing {% fill %} tags to the component. Accepts a dictionary of { slot_name: slot_content } where slot_content can be a string or render function. - escape_slots_content - Whether the content from slots should be escaped. - context - A context (dictionary or Django's Context) within which the component is rendered. The keys on the context can be accessed from within the template. - NOTE: In "isolated" mode, context is NOT accessible, and data MUST be passed via component's args and kwargs. - type - Configure how to handle JS and CSS dependencies. - "document" (default) - JS dependencies are inserted into {% component_js_dependencies %}, or to the end of the <body> tag. CSS dependencies are inserted into {% component_css_dependencies %}, or the end of the <head> tag. - request - The request object. This is only required when needing to use RequestContext, e.g. to enable template context_processors. Unused if context is already an instance of Context

Any additional args and kwargs are passed to the response_class.

Example:

MyComponent.render_to_response(
     args=[1, "two", {}],
     kwargs={
         "key": 123,
diff --git a/dev/reference/template_tags/index.html b/dev/reference/template_tags/index.html
index e7599b5e..69fcf310 100644
--- a/dev/reference/template_tags/index.html
+++ b/dev/reference/template_tags/index.html
@@ -3,7 +3,7 @@
 

See source code

Marks location where CSS link tags should be rendered after the whole HTML has been generated.

Generally, this should be inserted into the <head> tag of the HTML.

If the generated HTML does NOT contain any {% component_css_dependencies %} tags, CSS links are by default inserted into the <head> tag of the HTML. (See JS and CSS output locations)

Note that there should be only one {% component_css_dependencies %} for the whole HTML document. If you insert this tag multiple times, ALL CSS links will be duplicately inserted into ALL these places.

component_js_dependencies¤

{% component_js_dependencies  %}
 

See source code

Marks location where JS link tags should be rendered after the whole HTML has been generated.

Generally, this should be inserted at the end of the <body> tag of the HTML.

If the generated HTML does NOT contain any {% component_js_dependencies %} tags, JS scripts are by default inserted at the end of the <body> tag of the HTML. (See JS and CSS output locations)

Note that there should be only one {% component_js_dependencies %} for the whole HTML document. If you insert this tag multiple times, ALL JS scripts will be duplicately inserted into ALL these places.

component¤

{% component *args: Any, **kwargs: Any [only] %}
 {% endcomponent %}
-

See source code

Renders one of the components that was previously registered with @register() decorator.

Args:

  • name (str, required): Registered name of the component to render
  • All other args and kwargs are defined based on the component itself.

If you defined a component "my_table"

from django_component import Component, register
+

See source code

Renders one of the components that was previously registered with @register() decorator.

Args:

  • name (str, required): Registered name of the component to render
  • All other args and kwargs are defined based on the component itself.

If you defined a component "my_table"

from django_component import Component, register
 
 @register("my_table")
 class MyTable(Component):
diff --git a/dev/sitemap.xml b/dev/sitemap.xml
index bf00615a..9327b52c 100644
--- a/dev/sitemap.xml
+++ b/dev/sitemap.xml
@@ -2,226 +2,226 @@
 
     
          https://django-components.github.io/django-components/latest/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/SUMMARY/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/migrating_from_safer_staticfiles/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/release_notes/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/advanced/authoring_component_libraries/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/advanced/component_registry/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/advanced/hooks/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/advanced/html_tragments/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/advanced/provide_inject/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/advanced/rendering_js_css/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/advanced/tag_formatter/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/advanced/template_tags/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/advanced/typing_and_validation/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/fundamentals/access_component_input/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/fundamentals/autodiscovery/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/fundamentals/component_context_scope/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/fundamentals/components_as_views/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/fundamentals/components_in_python/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/fundamentals/defining_js_css_html_files/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/fundamentals/html_attributes/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/fundamentals/single_file_components/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/fundamentals/slots/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/fundamentals/subclassing_components/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/concepts/fundamentals/template_tag_syntax/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/getting_started/adding_js_and_css/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/getting_started/adding_slots/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/getting_started/components_in_templates/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/getting_started/parametrising_components/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/getting_started/your_first_component/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/guides/devguides/dependency_mgmt/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/guides/devguides/slot_rendering/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/guides/devguides/slots_and_blocks/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/guides/other/troubleshooting/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/guides/setup/caching/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/guides/setup/development_server/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/guides/setup/syntax_highlight/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/overview/code_of_conduct/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/overview/community/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/overview/compatibility/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/overview/contributing/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/overview/development/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/overview/installation/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/overview/license/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/overview/security_notes/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/overview/welcome/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/reference/api/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/reference/commands/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/reference/components/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/reference/exceptions/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/reference/middlewares/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/reference/settings/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/reference/signals/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/reference/tag_formatters/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/reference/template_tags/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/reference/template_vars/
-         2025-02-15
+         2025-02-16
     
     
          https://django-components.github.io/django-components/latest/reference/urls/
-         2025-02-15
+         2025-02-16
     
 
\ No newline at end of file
diff --git a/dev/sitemap.xml.gz b/dev/sitemap.xml.gz
index 03414f20..2dc3b8e1 100644
Binary files a/dev/sitemap.xml.gz and b/dev/sitemap.xml.gz differ
diff --git a/versions.json b/versions.json
index 9bc3402e..2b487452 100644
--- a/versions.json
+++ b/versions.json
@@ -1,7 +1,7 @@
 [
   {
     "version": "dev",
-    "title": "dev (3cf586a)",
+    "title": "dev (58d4c78)",
     "aliases": []
   },
   {