o 3a@srddlZddlmZddlmZddlmZddlmZddl m Z m Z ddl m Z dd lmZGd d d ZdS) N)ImproperlyConfigured)cached_property import_stringTemplate)Context_builtin_context_processors)TemplateDoesNotExistimport_libraryc@seZdZgdZ   d!ddZeed d Ze d d Z d dZ ddZ e ddZ ddZddZd"ddZddZddZd#ddZdd ZdS)$Engine)zdjango.template.defaulttagszdjango.template.defaultfilterszdjango.template.loader_tagsNFutf-8Tc Cs|durg}|dur g}|dur"dg}|r|dg7}|s!d|fg}n|r(td|dur.i}| dur4g} ||_||_| |_||_||_||_||_||_||_ | ||_ |j | |_ ||j |_dS)Nz)django.template.loaders.filesystem.Loaderz.django.template.loaders.app_directories.Loaderz%django.template.loaders.cached.Loaderz1app_dirs must not be set when loaders is defined.)rdirsapp_dirs autoescapecontext_processorsdebugloadersstring_if_invalid file_charset librariesget_template_librariestemplate_librariesdefault_builtinsbuiltinsget_template_builtinstemplate_builtins) selfrrrrrrrrrrr!8/usr/lib/python3/dist-packages/django/template/engine.py__init__s>    zEngine.__init__cCsBddlm}ddlm}|D] }t||r|jSqtd)a Return the first DjangoTemplates backend that's configured, or raise ImproperlyConfigured if none are configured. This is required for preserving historical APIs that rely on a globally available, implicitly configured engine such as: >>> from django.template import Context, Template >>> template = Template("Hello {{ name }}!") >>> context = Context({'name': "world"}) >>> template.render(context) 'Hello world!' r)engines)DjangoTemplatesz)No DjangoTemplates backend is configured.)django.templater$django.template.backends.djangor%all isinstanceenginer)r$r%r*r!r!r" get_default7s     zEngine.get_defaultcCs$t}|t|j7}tdd|DS)Ncss|]}t|VqdSNr).0pathr!r!r" Usz5Engine.template_context_processors..)r tupler)r rr!r!r"template_context_processorsQsz"Engine.template_context_processorscCsdd|DS)NcSsg|]}t|qSr!r )r-xr!r!r" Xsz0Engine.get_template_builtins..r!)r rr!r!r"rWszEngine.get_template_builtinscCs&i}|D] \}}t|||<q|Sr,)itemsr )r rloadednamer.r!r!r"rZszEngine.get_template_librariescCs ||jSr,)get_template_loadersr)r r!r!r"template_loaders`s zEngine.template_loaderscCs.g}|D]}||}|dur||q|Sr,)find_template_loaderappend)r r8rtemplate_loaderloaderr!r!r"r7ds  zEngine.get_template_loaderscCsJt|ttfr |^}}ng}t|trt|}||g|RStd|)Nz3Invalid value in template loaders configuration: %r)r)r0liststrrr)r r<args loader_classr!r!r"r9ls  zEngine.find_template_loaderc Csjg}|jD])}z|j||d}||jfWSty.}z ||jWYd}~qd}~wwt||d)N)skip)tried)r8 get_templateoriginr extendrB)r r6rrArBr<templateer!r!r" find_templateys  zEngine.find_templatecCs t||dS)z Return a compiled Template object for the given template code, handling template inheritance recursively. r*r)r template_coder!r!r" from_strings zEngine.from_stringcCs,||\}}t|dst||||d}|S)z Return a compiled Template object for the given template name, handling template inheritance recursively. renderrI)rHhasattrr)r template_namerFrDr!r!r"rCs zEngine.get_templatecCsLt|ttfr ||}n||}t|tr||S|t||jdS)z Render the template specified by template_name with the given context. For use in Django's test suite. )r)r)r=r0select_templaterCr rLr)r rNcontexttr!r!r"render_to_strings     zEngine.render_to_stringc Csz|stdg}|D]+}z||WSty5}z|jd|vr+||jdWYd}~q d}~wwtd|)zV Given a list of template names, return the first that can be loaded. zNo template names providedrNz, )r rCr?r:join)r template_name_list not_foundrNexcr!r!r"rOs zEngine.select_template) NFNFNrrNNT)NNr,)__name__ __module__ __qualname__rr# staticmethod functools lru_cacher+rr1rrr8r7r9rHrKrCrRrOr!r!r!r"r s, #      r)r[django.core.exceptionsrdjango.utils.functionalrdjango.utils.module_loadingrbaserrPr r exceptionsr libraryr rr!r!r!r"s