public function invalidateLoadedTemplates(): void
    {
        try {
            $me     = new \ReflectionClass($this);
            $parent = $me;

            while ($parent instanceof \ReflectionClass) {
                $me     = $parent;
                $parent = $me->getParentClass();
            }

            $templates = $me->getProperty('loadedTemplates');
            $templates->setAccessible(true);
            $templates->setValue($this, []);
        } catch (\ReflectionException $e) {
        }
    }
public function invalidateLoadedTemplates(): void
    {
        try {
            $me     = new \ReflectionClass($this);
            $parent = $me;

            while ($parent instanceof \ReflectionClass) {
                $me     = $parent;
                $parent = $me->getParentClass();
            }

            $templates = $me->getProperty('loadedTemplates');
            $templates->setAccessible(true);
            $templates->setValue($this, []);
        } catch (\ReflectionException $e) {
        }
    }
public function invalidateLoadedTemplates ( ) : void { try { $ me = new \ ReflectionClass ( $ this ) ; $ parent = $ me ; while ( $ parent instanceof \ ReflectionClass ) { $ me = $ parent ; $ parent = $ me -> getParentClass ( ) ; } $ templates = $ me -> getProperty ( 'loadedTemplates' ) ; $ templates -> setAccessible ( true ) ; $ templates -> setValue ( $ this , [ ] ) ; } catch ( \ ReflectionException $ e ) { } }
We aren't supposed to be using loadTemplate directly, and Twig V2 took away our ability to invalidate it.

Hacky workaround to expose invalidation.
We aren t supposed to be using loadTemplate directly and Twig V2 took away our ability to invalidate it .