o
    h                     @   sD   d dl mZ d dlmZ d dlmZ d dlmZ G dd deZdS )    )warn)Widget)	mark_safe)RemovedInWagtail70Warningc                       sD   e Zd Zededd  fddZdd Zdd	d
Zdd Z  Z	S )WidgetWithScriptzQThe usage of `WidgetWithScript` hook is deprecated. Use external scripts instead.   )category
stacklevelc                    s   t  |||S )z4Render the HTML (non-JS) portion of the field markup)superrender)selfnamevalueattrs	__class__ U/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/utils/widgets.pyrender_html   s   zWidgetWithScript.render_htmlc                 C   s   |S )Nr   )r   r   r   r   r   get_value_data   s   zWidgetWithScript.get_value_dataNc           
   	   C   sf   z|d }W n t tfy   tdw | |}| |||}| |||}| d| d}	t|	S )Nidz=WidgetWithScript cannot be rendered without an 'id' attributez<script>z	</script>)KeyError	TypeErrorr   r   render_js_initr   )
r   r   r   r   rendererid_
value_datawidget_htmljsoutr   r   r   r      s   
zWidgetWithScript.renderc                 C   s   dS )N r   )r   r   r   r   r   r   r   r   -   s   zWidgetWithScript.render_js_init)NN)
__name__
__module____qualname__r   r   r   r   r   r   __classcell__r   r   r   r   r   	   s    
r   N)	warningsr   django.forms.widgetsr   django.utils.safestringr   wagtail.utils.deprecationr   r   r   r   r   r   <module>   s
    