### Summary

`ansible.template.is_template` tries to loop until it determines if the value is indeed a template.  Which means we could loop extremely large strings, that don't even remotely look like templates, before we bail.

However, we could benefit from moving `Templar.is_possibly_template` to the global scope, and testing whether the value after `jinja_env.preprocess` is even possibly a template, before doing more computationally complex validation.

### Issue Type

Feature Idea

### Component Name

lib/ansible/template/__init__.py

### Additional Information

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)

```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
'''
        Our custom environment, which simply allows us to override the class-level
        values for the Template and Context classes used by jinja2 internally.
        NOTE: Any changes to this class must be reflected in
              :class:`AnsibleEnvironment` as well.
        '''
        context_class = AnsibleContext
        template_class = AnsibleJ2Template
        def __init__(self, *args, **kwargs):
            super(AnsibleNativeEnvironment, self).__init__(*args, **kwargs)
            self.filters = JinjaPluginIntercept(self.filters, filter_loader, jinja2_native=True)
            self.tests = JinjaPluginIntercept(self.tests, test_loader, jinja2_native=True)
class Templar:
    '''
    The main class for templating, with the main entry-point of template().
    '''
    def __init__(self, loader, shared_loader_obj=None, variables=None):