Add support for html_cva()
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3580788. -->
Reported by: [thamas](https://www.drupal.org/user/53339)
Related to !8
>>>
<h3 id="version">Version</h3>
<ul>
<li>Drupal version: 11.3.5 </li>
<li>Twig version: 3.4</li>
</ul>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>The <code>html_cva</code> function was added in Twig 3.12, and the CVA module makes it available in Drupal. But SDC Devel marks <code>html_cva</code> as "Unknown Twig function". </p>
<p>Also, <code>html_cva</code> needs to use <code>apply()</code>. But SDC Devel marks it as an error: "Direct method call are forbidden."</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>Use <code>html_cva</code> in an SDC. Eg.</p>
<pre>{% set section =<br> html_cva(<br> base: width == 'full' ? '' : 'px-5 lg:px-8',<br> variants: {<br> theme: {<br> dark: 'dark bg-theme-primary text-white',<br> light: 'light bg-neutral-light text-theme-primary'<br> }<br> }<br> )<br>%}<br><br>{% set attributes =<br> attributes.addClass(<br> [<br> section.apply({<br> theme<br> })<br> ]<br> )<br>%}<br><br><div {{ attributes }}><br> {{ section_content }}<br></div></pre><p>Then check the component with SDC Devel. It will return the problems mentioned above.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Instead of reporting the use of <code>html_cva</code> as an error, check if it is used correctly.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>?</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>None.</p>
<h3 id="summary-introduced-terminology">Introduced terminology</h3>
<p>?</p>
<h3 id="summary-api-changes">API changes</h3>
<p>?</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>?</p>
<h3 id="summary-release-notes">Release notes snippet</h3>
<p>?</p>
issue