Load module position in component layout template

What if you need to load a module inside a Joomla component?

Simple, not? Theory says, that you need to add this code to the template override of desired output, and you're done!

<jdoc:include type="module" name="mymoduleposition" />

Well, not allways..

There are situations, where the trick simply does not works. Why? There can be multiple causes, discussed in this site elsewhere, but if you need a quick and not-so-dirty solution here is an ancient 5liner, from Joomla 1.5 times, slightly adapted to the modern Joomla API wich simply works:

<?php $document = Factory::getDocument();
$renderer   = $document->loadRenderer('modules');
$position   = 'mymoduleposition';
$options   = array('style' => 'raw');
echo $renderer->render($position, $options, null); ?>