My goal is create a custom block that uses a twig template that you can pass info to via the theme function like so.
public function build() {
return array(
'#type' => 'markup',
'#markup' => $this->siteContent(),
);
}
public function siteContent() {
$source_text = some_function_returning_html_from_user();
return array(
'#theme' => 'scadfashblock',
'#source_text' => $source_text,
);
}
I got the above code from a tutorial trying to render a template file for a custom page. The problem is this code throws an error saying that an array can't be returned this way, it must be a string.
I even tried doing it the drupal 7 way...
public function build() {
return array(
'#type' => 'markup',
'#markup' => $this->siteContent(),
);
}
private function siteContent() {
$output = array();
$output['source_text'] = some_function_returning_html_from_user();
return theme('scadfashblock', $output);
}
This throws an error:
Call to undefined function
Drupal\<module>\Plugin\Block\theme()