I have found multiple threads related to calling helper function in .phtml.
But I have a case where I need to call phtml file in helper and return HTML.
I have used this code:
//Where $this->_resultPageFactory is the object of \Magento\Framework\View\Result\PageFactory
$resultPage = $this->_resultPageFactory->create();
$html = $resultPage->getLayout()
->createBlock("Vendor\Module\Block\Index")
->setTemplate("Vendor_Module::index.phtml")
->toHtml();
return $html;
It is working fine, but the problem is, it is effecting other stuff like Product title, Media gallery etc (it is changed after using above code)
So, how can I call .pthml from helper?