U
    8ÄT_  ã                   @   sD   d dl mZ d dlmZ ddd„Zddd„Zddd	„Zdd
d„ZdS )é   )Úengines)ÚTemplateDoesNotExistNc                 C   sd   g }t |ƒ}|D ]B}z| | ¡W   S  tk
rP } z| |¡ W 5 d}~X Y qX qt| |d�‚dS )zt
    Load and return a template for the given name.

    Raise TemplateDoesNotExist if no such template exists.
    N©Úchain)Ú_engine_listÚget_templater   Úappend)Útemplate_nameÚusingr   r   ÚengineÚe© r   ú:/tmp/pip-unpacked-wheel-dv63caxw/django/template/loader.pyr      s    r   c                 C   sœ   t | tƒrtd|  ƒ‚g }t|ƒ}| D ]P}|D ]F}z| |¡W     S  tk
rr } z| |¡ W 5 d}~X Y q.X q.q&| r�td | ¡|d�‚ntdƒ‚dS )z¹
    Load and return a template for one of the given names.

    Try names in order and return the first template found.

    Raise TemplateDoesNotExist if no such template exists.
    z�select_template() takes an iterable of template names but got a string: %r. Use get_template() if you want to load a single template by name.Nz, r   zNo template names provided)Ú
isinstanceÚstrÚ	TypeErrorr   r   r   r   Újoin)Ztemplate_name_listr
   r   r   r	   r   r   r   r   r   Úselect_template   s"    
þÿ r   c                 C   s4   t | ttfƒrt| |d�}nt| |d�}| ||¡S )z�
    Load a template and render it with a context. Return a string.

    template_name may be a string or a list of strings.
    ©r
   )r   ÚlistÚtupler   r   Úrender)r	   ÚcontextÚrequestr
   Útemplater   r   r   Úrender_to_string4   s    r   c                 C   s   | d krt  ¡ S t |  gS )N)r   Úallr   r   r   r   r   A   s    r   )N)N)NNN)N)Ú r   Ú
exceptionsr   r   r   r   r   r   r   r   r   Ú<module>   s
   


