Return the contents of a template from a custom Twig function in a module?
There is no craft() function in Craft 3 and there are no Modules in Craft 2.
You probably mix the two different versions.
Craft 3
Craft::$app-&gt;getView()-&gt;renderTemplate('/path/to/template');

Of course you need to be in the correct namespace. You have to either use Craft or do \Craft
Craft 2
craft()-&gt;templates-&gt;render('path/to/template')