Fix #18526: ``with``handles missing variables incorrectly if you have set ``TEMPLATE_STRING_IF_INVALID``.