U ).ó_Kã@sœdZddlmZddlmZddlmZddlmZddlmZddl m Z dd l m Z d d „Z Gd d „d eƒZGdd„deƒZ dd„Zdd„Zdd„ZdS)zŠ flask.templating ~~~~~~~~~~~~~~~~ Implements the bridge to Jinja2. :copyright: 2010 Pallets :license: BSD-3-Clause é)Ú BaseLoader)Ú Environment)ÚTemplateNotFoundé)Ú_app_ctx_stack)Ú_request_ctx_stack)Úbefore_render_template)Útemplate_renderedcCsBtj}tj}i}|dk r"|j|d<|dk r>|j|d<|j|d<|S)zSDefault template context processor. Injects `request`, `session` and `g`. NÚgÚrequestÚsession)rÚtoprr r r )ZreqctxZappctxÚrv©rúŸC:\Users\Miouzora\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\flask/templating.pyÚ_default_template_ctx_processors   rc@seZdZdZdd„ZdS)rzÌWorks like a regular Jinja2 environment but has some additional knowledge of how Flask's blueprint works so that it can prepend the name of the blueprint to referenced templates if necessary. cKs,d|kr| ¡|d<tj|f|Ž||_dS)NÚloader)Zcreate_global_jinja_loaderÚBaseEnvironmentÚ__init__Úapp)ÚselfrÚoptionsrrrr*s zEnvironment.__init__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrr$src@s@eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dS)ÚDispatchingJinjaLoaderz\A loader that looks for templates in the application and all the blueprint folders. cCs ||_dS©N)r)rrrrrr6szDispatchingJinjaLoader.__init__cCs$|jjdr| ||¡S| ||¡S)NZEXPLAIN_TEMPLATE_LOADING)rÚconfigÚ_get_source_explainedÚ_get_source_fast)rÚ environmentÚtemplaterrrÚ get_source9s  z!DispatchingJinjaLoader.get_sourcec Cs”g}d}| |¡D]N\}}z| ||¡}|dkr4|}Wntk rNd}YnX| |||f¡qddlm}||j||ƒ|dk rˆ|St|ƒ‚dS)Nr)Ú!explain_template_loading_attempts)Ú _iter_loadersr#rÚappendZ debughelpersr$r) rr!r"ÚattemptsZtrvÚsrcobjrrr$rrrr>s   z,DispatchingJinjaLoader._get_source_explainedc CsL| |¡D]4\}}z| ||¡WStk r<Yq Yq Xq t|ƒ‚dSr)r%r#r)rr!r"Z_srcobjrrrrr Ss  z'DispatchingJinjaLoader._get_source_fastccsH|jj}|dk r|j|fV|j ¡D]}|j}|dk r&||fVq&dSr)rÚ jinja_loaderÚiter_blueprints)rr"rÚ blueprintrrrr%[s z$DispatchingJinjaLoader._iter_loaderscCsbtƒ}|jj}|dk r$| | ¡¡|j ¡D]*}|j}|dk r.| ¡D]}| |¡qHq.t|ƒSr)Úsetrr)ÚupdateÚlist_templatesr*ÚaddÚlist)rÚresultrr+r"rrrr.es z%DispatchingJinjaLoader.list_templatesN) rrrrrr#rr r%r.rrrrr1s rcCs.tj|||d| |¡}tj|||d|S)z)Renders the template and fires the signal)r"Úcontext)rÚsendÚrenderr )r"r2rrrrrÚ_renderts r5cKs*tj}|j |¡t|jj |¡||jƒS)a–Renders a template from the template folder with the given context. :param template_name_or_list: the name of the template to be rendered, or an iterable with template names the first one existing will be rendered :param context: the variables that should be available in the context of the template. )rr rÚupdate_template_contextr5Ú jinja_envZget_or_select_template)Ztemplate_name_or_listr2ÚctxrrrÚrender_template}s   ýr9cKs*tj}|j |¡t|jj |¡||jƒS)aFRenders a template from the given template source string with the given context. Template variables will be autoescaped. :param source: the source code of the template to be rendered :param context: the variables that should be available in the context of the template. )rr rr6r5r7Z from_string)Úsourcer2r8rrrÚrender_template_strings  r;N)rZjinja2rrrrÚglobalsrrZsignalsrr rrr5r9r;rrrrÚs        C