I am trying to pass variables to a custom block in a module. I can see that the custom block is used in the code, however I cannot get the variables to show up.
Any help much appreciated:
I am themeing the block in the module file
function etypeservices_theme($existing, $type, $theme, $path) {
return [
'block__etypeservices' => [
'variables' => [
'facebook' => '',
],
],
];
}
I am building the render array
class SocialBlock extends BlockBase implements BlockPluginInterface {
/**
* {@inheritdoc}
*/
public function build() {
$config = \Drupal::config('etypeservices.settings');
$facebook = $config->get('facebook');
return [
'#theme' => 'block__etypeservices',
'#facebook' => $facebook,
];
}
}
and here is the template
{%
set classes = [
'block',
'block-social-icons',
]
%}
<div{{ attributes.addClass(classes) }}>
<ul class="list-style-none">
{% if facebook %}
<li><a href="https://www.facebook.com/{{ facebook }}" target="_blank">Facebook</a></li>
{% endif %}
</ul>
</div>
Can anybody see why this is not working?