Quantcast
Viewing all articles
Browse latest Browse all 295845

SDC componentMetadata does not take the right context when a component is extended

Problem/Motivation

Using SDC there is a problem when a component extends from another and wants to use the componentMetadata object in order to, for instance, use the Component path information to load some images from the component's folder.

Steps to reproduce

As the sdc_examples module shows here, the problem comes when a component uses the extend inside their template expecting the files from that component to be loaded but instead the ones coming from the extended component end up showing.

Proposed resolution

I guess the componentMetadata object should get the right context depending the component which ends up being loaded.

As a workaround a twig block can be used from the extended component in order to apply the right componentMetadata information as the following example shows:

{% set metadata = componentMetadata %}
{% embed 'sdc_example:my-button--primary' %}
  {% block iconTypeBlock %}
    {{ source(metadata.path ~ '/img/' ~ iconType|default('power') ~ '.svg') }}
  {% endblock %}
{% endembed %}

Viewing all articles
Browse latest Browse all 295845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>