I have a Twig template for a custom block. My custom module is establishing what template is used like so
function mymodule_theme($existing, $type, $theme, $path){
return array('mymodule' =>
array(
'variables' => array(
'header-title' => 'Default Title',
'header-size' => 'h1'
),
'template' => 'block--HeaderText'
)
);
}
and my custom block contains.
public function build() {
return array(
'#theme' => 'mymodule',
'#title' => '',
'#header-title' => $this->configuration['label'],
'#header-size' => $this->configuration['header-size-submit'],
);
}
And in my block--HeaderText.html.twig I have
<h2>{{ header-title }}</h2> This is a test {{ header-size }}
{{ dump() }}
However header-title and header-size both output 0. But using the dump() function in the template shows that the actual variables are available some how.
The dump() produces
array(15) { ["header-title"]=> string(19) "Header Textsdfgsdfg" ["header-size"]=> string(2) "h4"...
Yet {{ header-title }} just results in 0.