I have used below code in magento1 to load the static block with custom variables.
Here is the code of my m1 Block file.
{
$customer = Mage::getSingleton('customer/session')->getCustomer();
$block = Mage::getModel('cms/block')
->setStoreId(Mage::app()->getStore()->getId())
->load('static_block_id');
if($block->getIsActive()) {
$array = array();
$array['custom_value1'] = $formattedPrice = Mage::helper('core')->currency($customer->getNoofOrders(), true, false);
$array['custom_value2'] = $formattedPrice = Mage::helper('core')->currency($customer->getSavingsToDate(), true, false);
$array['registration_date'] = date('F Y', strtotime($customer->getRegistrationDate()));
$filter = Mage::getModel('cms/template_filter');
$filter->setVariables($array);
// return the filtered block content.
return $filter->filter($block->getContent());
}
Here getNoofOrders and getSavingsToDate are the custom customer attributes.
How can i use the same code in magento 2 format. If so please anybody help me with this how to set the custom variables and that is used in static blocks. Thanks