o
    `oi	                     @   sx   d dl mZ d dlmZmZ d dlmZmZ d dlm	Z	 d dl
mZ d dlmZmZ d dlmZmZ eedd	 Zd
S )    )signing)HttpResponseBadRequestJsonResponse)OriginTemplateDoesNotExist)Engine)render_to_string)format_html	mark_safe)render_with_toolbar_languagerequire_show_toolbarc              	   C   sL  | j d}|du rtdS zt|}W n ty"   td Y S w | j d|}g }t j}|D ]}|durIt	|drD||j
7 }q3|| q3|D ]}t|}z||}W  n tyc   Y qLw d| }zdd	lm} dd
lm}	 ddlm}
 W n ty   td|}Y nw |||
 |	 }t|}td||d}td|iS )z`
    Return the source of a template, syntax-highlighted by Pygments if
    it's available.
    Ztemplate_originNz!"template_origin" key is requiredz"template_origin" is invalidtemplateloaderszTemplate Does Not Exist: r   )	highlight)HtmlFormatter)HtmlDjangoLexerz<code>{}</code>z)debug_toolbar/panels/template_source.html)sourcetemplate_namecontent)GETgetr   r   loads	Exceptionr   get_defaultZtemplate_loadershasattrr   appendr   Zget_contentsr   pygmentsr   Zpygments.formattersr   Zpygments.lexersr   ModuleNotFoundErrorr	   r
   r   r   )requestZtemplate_origin_namer   Zfinal_loadersr   loaderoriginr   r   r   r   r    r!   l/var/www/html/kuke-dev/django-kuke/venv/lib/python3.10/site-packages/debug_toolbar/panels/templates/views.pytemplate_source   sP   




r#   N)Zdjango.corer   Zdjango.httpr   r   Zdjango.templater   r   Zdjango.template.enginer   Zdjango.template.loaderr   Zdjango.utils.htmlr	   r
   Zdebug_toolbar.decoratorsr   r   r#   r!   r!   r!   r"   <module>   s    