README.txt

The API of Single Directory Components includes:

  - The component plugin manager (the service with name plugin.manager.sdc).
    This service will be needed by modules that need to find and instantiate
    components.
  - The exceptions. Code using Single Directory Components can rely, and extend,
    the exceptions provided by the experimental module.
  - The folder structure of a component and the naming conventions of the files
    in it.
  - The structure of the component metadata (the my-component.component.yml).
    Note that the metadata of the component is described, and optionally
    validated, by the schema in metadata.schema.json (this file is for internal validation and not part of the API).
  - The render element and its class \Drupal\Core\Render\Element\ComponentElement.
  - The naming convention for the ID when using Twig's include, embed, and
    extends. This naming convention is [module/theme]:[component machine name].
    See the example below.

{% embed 'my-theme:my-component' with { prop1: content.field_for_prop1 } %}
  {% block slot1 %}
    {{ content|without('field_for_prop1') }}
  {% endblock %}
{% endembed %}

This way  of specifying the component for Twig's include, embed, and
extends('my-theme:my-component' in the example) will not change, as it is
considered an API.

File

core/modules/sdc/README.txt

View source
  1. The API of Single Directory Components includes:
  2. - The component plugin manager (the service with name plugin.manager.sdc).
  3. This service will be needed by modules that need to find and instantiate
  4. components.
  5. - The exceptions. Code using Single Directory Components can rely, and extend,
  6. the exceptions provided by the experimental module.
  7. - The folder structure of a component and the naming conventions of the files
  8. in it.
  9. - The structure of the component metadata (the my-component.component.yml).
  10. Note that the metadata of the component is described, and optionally
  11. validated, by the schema in metadata.schema.json (this file is for internal validation and not part of the API).
  12. - The render element and its class \Drupal\Core\Render\Element\ComponentElement.
  13. - The naming convention for the ID when using Twig's include, embed, and
  14. extends. This naming convention is [module/theme]:[component machine name].
  15. See the example below.
  16. {% embed 'my-theme:my-component' with { prop1: content.field_for_prop1 } %}
  17. {% block slot1 %}
  18. {{ content|without('field_for_prop1') }}
  19. {% endblock %}
  20. {% endembed %}
  21. This way of specifying the component for Twig's include, embed, and
  22. extends('my-theme:my-component' in the example) will not change, as it is
  23. considered an API.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.