
v^                 @   sf   d  d l  m Z d  d l m Z d d d  Z d d d  Z d d d d d	  Z d d
 d  Z d S)   )engines)TemplateDoesNotExistNc             C   s   g  } t  |  } xT | D]L } y | j |   SWq t k
 rd } z | j |  WYd d } ~ Xq Xq Wt |  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   8/tmp/pip-build-8lau8j11/django/django/template/loader.pyr      s    $r   c             C   s   t  |  t  r t d |    g  } t |  } xe |  D]] } xT | D]L } y | j |  SWqE t k
 r } z | j |  WYd d } ~ XqE XqE Wq8 W|  r t d j |   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.
    zselect_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   sL   t  |  t t f  r* t |  d | } n t |  d | } | j | |  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  j   St  |  g S)N)r   all)r	   r   r   r   r   A   s    r   ) r   
exceptionsr   r   r   r   r   r   r   r   r   <module>   s
   