1. Documentation
  2. Components
  3. Component - Layer

Layer component

The layer component functions as an abstract wrapper that encapsulates other components within the Unfold system. Its primary purpose is to provide a mechanism for injecting variables that are generated by component classes, enabling seamless data flow from your Python logic to the template rendering layer.

# admin.py

from unfold.components import register_component, BaseComponent


@register_component
class SomeComponent(BaseComponent):
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context.update({
            "some_variable": [
                {
                    "title": "Example A",
                },
                {
                    "title": "Example B",
                }
            ]
        })
        return context
{% load unfold %}

{% component "unfold/components/layer.html" with component_class="SomeComponent" %}
    {% for item in some_variable %}
        {{ item.title }}
    {% endfor %}
{% endcomponent %}

© 2023 - 2025 Created by unfoldadmin.com. All rights reserved.