I am working on a custom slider programmatically. I create a Custom Module (block_example) and make a block (BlockExample.php) and a twig file (blockexample.html.twig) and also a module file (block_example.module). I want to place some code in twig file and call it in block file.
this is build function frome block file (BlockExample.php)
public function build() {
$renderable = (
'#theme' => 'blockexample',
);
return $renderable;
}
this is (blockexample.html.twig) file code
<div class="col-sm-3">
<h1>This is Title</h1>
<p>Description Coming From Twig File</p>
</div>
this is (block_example.module) file code
function block_example_theme() {
return array(
'block_example' => (
'variables' => ('test_var' => NULL),
),
);
}
Now main question is how to print twig file in BlockExample.php