U ‘Ï aúã@sddlZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd l m Z dd l m Z ejr†dd lmZdd lmZejeejfd œdd„ZGdd„deƒZGdd„deƒZeededœdd„Zejeejefejedœdd„Zeejedœdd„ZdS)éN)Ú BaseLoader)Ú Environment)ÚTemplate)ÚTemplateNotFoundé)Ú_app_ctx_stack)Ú_request_ctx_stack)Úbefore_render_template)Útemplate_rendered)ÚFlask)ÚScaffold©ÚreturncCsBtj}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Útoprrrr)ZreqctxZappctxÚrv©rúQC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-e702oxwa\flask\templating.pyÚ_default_template_ctx_processors   rc@s$eZdZdZdejddœdd„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. r N)ÚappÚoptionsrcKs,d|kr| ¡|d<tj|f|Ž||_dS)NÚloader)Zcreate_global_jinja_loaderÚBaseEnvironmentÚ__init__r)Úselfrrrrrr's zEnvironment.__init__)Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚtÚAnyrrrrrr!src@sÞeZdZdZdddœdd„Zeeejeej eej ej fdœdd „Z eeejeej eej ej fdœd d „Z eeejeej eej ej fdœd d „Z eejejdefddfdœdd„Zejedœdd„ZdS)ÚDispatchingJinjaLoaderz\A loader that looks for templates in the application and all the blueprint folders. r N)rrcCs ||_dS©N)r)rrrrrr3szDispatchingJinjaLoader.__init__)Ú environmentÚtemplatercCs$|jjdr| ||¡S| ||¡S)NZEXPLAIN_TEMPLATE_LOADING)rÚconfigÚ_get_source_explainedÚ_get_source_fast)rr%r&rrrÚ get_source6s  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)Ws  z'DispatchingJinjaLoader._get_source_fastr )r&rccsH|jj}|dk r|j|fV|j ¡D]}|j}|dk r&||fVq&dSr$)rÚ jinja_loaderÚiter_blueprints)rr&rÚ blueprintrrrr,as z$DispatchingJinjaLoader._iter_loadersr cCsbtƒ}|jj}|dk r$| | ¡¡|j ¡D]*}|j}|dk r.| ¡D]}| |¡qHq.t|ƒSr$)Úsetrr0ÚupdateÚlist_templatesr1ÚaddÚlist)rÚresultrr2r&rrrr5ms z%DispatchingJinjaLoader.list_templates)rrrr rrÚstrr!ÚTupleÚOptionalÚCallabler*r(r)Ú Generatorrr,ÚListr5rrrrr#.s$þ þ þ þ r#r )r&ÚcontextrrcCs.tj|||d| |¡}tj|||d|S)z)Renders the template and fires the signal)r&r?)r ÚsendÚrenderr )r&r?rrrrrÚ_render|s rB)Útemplate_name_or_listr?rcKs*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. )rrrÚupdate_template_contextrBÚ jinja_envZget_or_select_template)rCr?ÚctxrrrÚrender_template…s   ýrG)Úsourcer?rcKs*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. )rrrrDrBrEZ from_string)rHr?rFrrrÚrender_template_stringšs  rI)Útypingr!Zjinja2rrrrrÚglobalsrrZsignalsr r Ú TYPE_CHECKINGrr Zscaffoldr ÚDictr9r"rr#ÚdictrBÚUnionr>rGrIrrrrÚs(           N þ