8 changed files with 70 additions and 7 deletions
@ -0,0 +1,15 @@
|
||||
Using it |
||||
|
||||
From any Twig template in your theme, use include with the namespaced name. The namespace is your theme's machine name: |
||||
|
||||
twig |
||||
{{ include('mytheme:test-card', { heading: 'Hello' }, with_context = false) }} |
||||
|
||||
For slots, use embed: |
||||
|
||||
twig |
||||
{% embed 'mytheme:test-card' with { heading: 'Hello' } %} |
||||
{% block body %} |
||||
<p>Some content here.</p> |
||||
{% endblock %} |
||||
{% endembed %} |
||||
@ -0,0 +1,12 @@
|
||||
$schema: https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json |
||||
name: Thing1 |
||||
status: experimental |
||||
props: |
||||
type: object |
||||
properties: |
||||
heading: |
||||
type: string |
||||
title: Heading |
||||
slots: |
||||
body: |
||||
title: Body |
||||
@ -0,0 +1,9 @@
|
||||
(function (Drupal, once) { |
||||
Drupal.behaviors.thing1 = { |
||||
attach(context) { |
||||
once("thing1", ".thing1", context).forEach((el) => { |
||||
// your code
|
||||
}); |
||||
}, |
||||
}; |
||||
})(Drupal, once); |
||||
@ -0,0 +1,6 @@
|
||||
<div {{ attributes.addClass('thing1') }}> |
||||
<h3 class="thing1__heading">{{ heading }}</h3> |
||||
<div class="thing1__body"> |
||||
{% block body %}{% endblock %} |
||||
</div> |
||||
</div> |
||||
Loading…
Reference in new issue