o
    ci                     @   s6   d dl Z d dlmZ d dlmZ eG dd dZdS )    N)List)DeveloperAPIc                   @   sD   e Zd ZdZdefddZdefddZedee	j
 fdd	Zd
S )Templatez+Class which provides basic HTML templating.filec                 C   sJ   t ttjd | d}| | _W d    d S 1 sw   Y  d S )N	templatesr)openpathlibPath__file__parentreadtemplate)selfr   f r   F/home/ubuntu/.local/lib/python3.10/site-packages/ray/widgets/render.py__init__   s   "zTemplate.__init__returnc                 K   sL   | j }| D ]\}}t|trd|}|d| d |r |nd}q|S )a  Render an HTML template with the given data.

        This is done by replacing instances of `{{ key }}` with `value`
        from the keyword arguments.

        Returns:
            HTML template with the keys of the kwargs replaced with corresponding
                values.
         z{{ z }})r   items
isinstancer   joinreplace)r   kwargsrenderedkeyvaluer   r   r   render   s   


zTemplate.renderc                   C   s   t tjd dS )zList the available HTML templates.

        Returns:
            A list of files with .html.j2 extensions inside ../templates/
        r   z	*.html.j2)r	   r
   r   r   globr   r   r   r   list_templates    s   zTemplate.list_templatesN)__name__
__module____qualname____doc__strr   r   staticmethodr   r	   r
   r    r   r   r   r   r      s    r   )r	   typingr   ray.util.annotationsr   r   r   r   r   r   <module>   s
    