We aren't supposed to be using loadTemplate directly, and Twig V2 took away our ability to invalidate it.

Hacky workaround to expose invalidation.
511480
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) {
        }
    }
61735
function(tplname, tplargs, tplloader) {
            tplname = tplname || this.template;
            tplargs = tplargs || _.result(this, "templateContext");
            tplloader = tplloader || _.result(this, "templateLoader");

            var tpl = new Template({
                template: tplname,
                args: tplargs,
                loader: tplloader,
                view: this
            });
            return tpl.render();
        }
951066
function loadTemplates() {
  const templatesPath = path.join(process.cwd(), plugin.config.templatesPath);

  return plugin.myrmex.fire('beforeTemplatesLoad')
  .then(() => {
    // Retrieve paths of all node packages
    return Promise.promisify(fs.readdir)(templatesPath);
  })
  .then(files => {
    // Load all packages configurations
    const templatePromises = [];
    _.forEach(files, (fileName) => {
      const templatePath = path.join(templatesPath, fileName);
      // subdir is the identifier of the template, so we pass it as the second argument
      templatePromises.push(loadTemplate(templatePath, fileName));
    });
    return Promise.all(templatePromises);
  })
  .then(templates => {
    // This event allows to inject code to add or delete or alter node templates configurations
    return plugin.myrmex.fire('afterTemplatesLoad', templates);
  })
  .spread(templates => {
    return Promise.resolve(templates);
  })
  .catch(e => {
    // In case the project does not have any template yet, an exception will be thrown
    // We silently ignore it
    if (e.code === 'ENOENT' && path.basename(e.path) === 'templates') {
      return Promise.resolve([]);
    }
    return Promise.reject(e);
  });
}
1005507
function loadTemplate(templatePath, identifier) {
  return plugin.myrmex.fire('beforeTemplateLoad', templatePath, identifier)
  .spread((templatePath, name) => {
    const templateDoc = _.cloneDeep(require(path.join(templatePath)));

    // Lasy loading because the plugin has to be registered in a Myrmex instance before requiring the document
    const Template = require('./template');
    const template = new Template(templateDoc, identifier);

    // This event allows to inject code to alter the template configuration
    return plugin.myrmex.fire('afterTemplateLoad', template);
  })
  .spread(template => {
    return Promise.resolve(template);
  });
}
271199
public TemplateCompilationResults reloadContextAndTemplates(boolean all)
        throws Exception {

        // Create the new merged context source
        TeaServletContextSource contextSource =
            new TeaServletContextSource(
                mApplicationDepot.getClass().getClassLoader(),
                mApplicationDepot,
                getServletContext(),
                getLog(),
                true,
                mProperties.getBoolean("management.httpcontext", false),
                mProperties.getInt("management.httpcontext.readUrlCacheSize", 500),
                isProfilingEnabled());

        // Create a new template source using the newly loaded context
        // source from the new application depot
        TeaServletTemplateSource templateSrc =
            createTemplateSource(contextSource);

        // Recompile all templates using the new context source
        TemplateCompilationResults results =
            templateSrc.compileTemplates(null, all);

        // The new context source and template source are ready for
        // use, set the member variables
        synchronized(this) {
            mApplicationDepot.setContextSource(contextSource);
            mTemplateSource = templateSrc;
        }

        // Return the compilation results
        return results;
    }
102365
function replaceWithTemplateType(start, end) {
    var templateToken = {
      type: "Template",
      value: createTemplateValue(start, end),
      start: tokens[start].start,
      end: tokens[end].end,
      loc: {
        start: tokens[start].loc.start,
        end: tokens[end].loc.end
      }
    };

    // put new token in place of old tokens
    tokens.splice(start, end - start + 1, templateToken);
  }
74276
function() {

		var result = null,
			index = this._active_argument_index;

		if (index != -1) {

			if (!this._content[index]) {

				this._content[index] = (index == 0)
					? new Lava.system.Template(this._config.template || [], this._widget, this, {if_index: index})
					: new Lava.system.Template(this._config.elseif_templates[index - 1] || [], this._widget, this, {if_index: index});

			}

			result = this._content[index];

		} else if ('else_template' in this._config) {

			if (this._else_content == null) {

				this._else_content = new Lava.system.Template(this._config.else_template || [], this._widget, this);

			}

			result = this._else_content;

		}

		return result;

	}
357260
public function setTemplate()
    {
        // Creates the loader & sets the template directory path
        $loader = new FilesystemLoader('../src/View');

        // Creates the template engine
        $twig = new Environment($loader, array(
            'cache' => false,
            'debug' => true
        ));

        // Adds Twig extensions
        $twig->addExtension(new DebugExtension());
        $twig->addExtension(new PamTwigExtension());

        // Attributes the template engine to the current object
        $this->twig = $twig;
    }
199876
function readTemplate() {
    return fs.readFileSync(path.resolve.apply(null, [__dirname, settings.paths.templates, ...arguments]), 'utf8');
}
58404
private Template getTemplate(String templateName) throws ParseException {
    try {
      return config.getTemplate(templateName, "UTF-8");
    } catch (ParseException e) {
      throw e;
    } catch (IOException e) {
      logger.error("Couldn't load template '{}',loader is {}", templateName,
          config.getTemplateLoader().getClass());
      throw Throwables.propagate(e);
    }
  }
823009
function cachedTemplateTree( $keyData, $uri, $res, $templatePath, &$extraParameters, $timestamp )
    {
        $key = $this->cacheKey( $keyData, $res, $templatePath, $extraParameters );
        if ( eZTemplateTreeCache::canRestoreCache( $key, $timestamp, $templatePath ) )
            eZTemplateTreeCache::restoreCache( $key, $templatePath );
        return eZTemplateTreeCache::cachedTree( $key, $uri, $res, $templatePath, $extraParameters );
    }
1202014
private function loadTemplate() {

		if(!empty($this->template)) {
			return true;
		}

		$path = Application::getInstance()->getRootPath() . (defined('FORMTEMPLATES_PATH') ? str_replace('/', DIRECTORY_SEPARATOR, ltrim(FORMTEMPLATES_PATH, '/')) : '');

		if(!file_exists($path . $this->tplFile)) {
			throw new HtmlFormException("Template file '$path{$this->tplFile}' does not exist.", HtmlFormException::TEMPLATE_FILE_NOT_FOUND);
		}

		$this->template = @file_get_contents($path . $this->tplFile);

		return true;
	}
513584
@Deprecated
	public static void removeTemplate(Client client, String template) {
		logger.trace("removeTemplate({})", template);
		client.admin().indices().prepareDeleteTemplate(template).get();
		logger.trace("/removeTemplate({})", template);
	}
804676
function setCachedTemplateTree( $keyData, $uri, $res, $templatePath, &$extraParameters, &$root )
    {
        $key = $this->cacheKey( $keyData, $res, $templatePath, $extraParameters );
        eZTemplateTreeCache::setCachedTree( $key, $uri, $res, $templatePath, $extraParameters, $root );
        eZTemplateTreeCache::storeCache( $key, $templatePath );
    }
983846
function processTemplate(val, data) {
	if (rbot.env.usingGrunt) {
		return rbot.env.taskRunner.template.process(val, data);
	}
	// TODO : add gulp template processing
	if (!val) {
		return val;
	}
	return val;
}
3149
function getTemplate(template, options) {
  stack.clear();
  parser.reset();

  let opts = typeof options === 'undefined' ? {} : options;
  opts.strict = typeof opts.strict === 'boolean' ? opts.strict : true;
  opts.preserveWhitespace = typeof opts.preserveWhitespace === 'boolean' ? opts.preserveWhitespace : false;
  opts.validateHtml = opts.validateHtml != null ? opts.validateHtml : 'strict';
  opts.logger = opts.logger != null ? opts.logger : {};

  let lambdas = {};
  if (_.isArray(opts.lambdas)) {
    for (let i = 0; i < opts.lambdas.length; i++) {
      lambdas[opts.lambdas[i]] = true;
    }
  }
  opts.lambdas = lambdas;
  opts.processingHTML = typeof opts.processingHTML === 'boolean' ? opts.processingHTML : true;

  compilerLogger.setStrictMode(opts.strict);
  compilerLogger.setOverrides(opts.logger);
  stack.setHtmlValidation(opts.validateHtml);

  let templateStr = template.toString();

  processTemplate(templateStr, opts);

  let output = {};

  if (stack.stack.length > 0) {
    compilerErrors.notAllTagsWereClosedProperly(stack.stack);
  }

  parser.end();
  output.templateObj = stack.getOutput();
  const Template = require('../template');
  output.template = new Template(output.templateObj);
  output.source = template;
  output.tokens = {};
  _.each(stack.tokens, function(values, type) {
    output.tokens[type] = _.keys(values);
  });
  return output;
}
556654
public function twigRender ($template_file = null, $render = null, $template_dir_list = [], $options = []) {
		$this->renderSetting();
		$template = $this->twigLoadFileTemplate($template_file, $template_dir_list, $options);
		$render = $this->adjustRender($render);
		return $template->render($render);
	}