In Drupal 8 what is the process for creating blocks with html and javascript?
Here is my sample code for creating the block
class TopNewsBlock extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
//Fetch data
return array(
'type' => 'markup',
'#markup' => '<table id="example_table"></table>',
'#attached' => array(
'library' => array(
'custom_cms_blocks/dataTables.dataTablesjs',
'custom_cms_blocks/top-news-library'
),
),
);
}
}
It works but the problem I have is - I want to seperate out the html code from the php code. Is it possible to include a html file within the block just like the way a javascript file is attached as a library?