Magento 2, Magento basic, Magento2 Optimization, Magento2.2, Uncategorized

Solution for : Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: ‘vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml’ in module: ” block’s name: ‘require.js’ in maento 2

Error Message:
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: ‘vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml’ in module: ” block’s name: ‘require.js’0 vendor\magento\framework\View\Element\Template.php(300): Magento\Framework\View\Element\Template->fetchView(‘C:/xampp/htdocs…’) vendor\magento\framework\View\Element\AbstractBlock.php(667): Magento\Framework\View\Element\Template->_toHtml() vendor\magento\framework\View\Result\Page.php(248): Magento\Framework\View\Element\AbstractBlock->toHtml() vendor\magento\framework\View\Result\Layout.php(170): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor)) vendor\magento\framework\Interception\Interceptor.php(58): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor)) vendor\magento\framework\Interception\Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor->___callParent(‘renderResult’, Array) vendor\magento\framework\Interception\Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Response\Http\Interceptor)) generated\code\Magento\Framework\View\Result\Page\Interceptor.php(130): Magento\Framework\View\Result\Page\Interceptor->___callPlugins(‘renderResult’, Array, Array)

After install the magento 2.2.7 – We got the above error message on console section.
After done the following steps also we recieved same kind of issue & even after done below steps my website is blank.

Solution:
For this kind issues we need to do some modification from core file level in this version. Go to Following file vendor/magento/framework/view/element/template/file/validator.php
protected function isPathInDirectories($path, $directories)
{
$realPath = str_replace(‘\’, ‘/’, $this->fileDriver->getRealPath($path)); //Add this LINE
if (!is_array($directories)) {
$directories = (array)$directories;
}
foreach ($directories as $directory) {
if (0 === strpos($realPath, $directory)) {
return true;
}
}
return false;
}

Clear cache & check. It will work.