Spaces:
Sleeping
Sleeping
| # Component extensions | |
| <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! --> | |
| ``` python | |
| from pprint import pprint | |
| ``` | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L26" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### A | |
| > A (*c, hx_get=None, target_id=None, hx_swap=None, href='#', hx_vals=None, | |
| > hx_target=None, id=None, cls=None, title=None, style=None, | |
| > accesskey=None, contenteditable=None, dir=None, draggable=None, | |
| > enterkeyhint=None, hidden=None, inert=None, inputmode=None, lang=None, | |
| > popover=None, spellcheck=None, tabindex=None, translate=None, | |
| > hx_post=None, hx_put=None, hx_delete=None, hx_patch=None, | |
| > hx_trigger=None, hx_swap_oob=None, hx_include=None, hx_select=None, | |
| > hx_select_oob=None, hx_indicator=None, hx_push_url=None, | |
| > hx_confirm=None, hx_disable=None, hx_replace_url=None, | |
| > hx_disabled_elt=None, hx_ext=None, hx_headers=None, hx_history=None, | |
| > hx_history_elt=None, hx_inherit=None, hx_params=None, | |
| > hx_preserve=None, hx_prompt=None, hx_request=None, hx_sync=None, | |
| > hx_validate=None, hx_on_blur=None, hx_on_change=None, | |
| > hx_on_contextmenu=None, hx_on_focus=None, hx_on_input=None, | |
| > hx_on_invalid=None, hx_on_reset=None, hx_on_select=None, | |
| > hx_on_submit=None, hx_on_keydown=None, hx_on_keypress=None, | |
| > hx_on_keyup=None, hx_on_click=None, hx_on_dblclick=None, | |
| > hx_on_mousedown=None, hx_on_mouseenter=None, hx_on_mouseleave=None, | |
| > hx_on_mousemove=None, hx_on_mouseout=None, hx_on_mouseover=None, | |
| > hx_on_mouseup=None, hx_on_wheel=None, hx_on__abort=None, | |
| > hx_on__after_on_load=None, hx_on__after_process_node=None, | |
| > hx_on__after_request=None, hx_on__after_settle=None, | |
| > hx_on__after_swap=None, hx_on__before_cleanup_element=None, | |
| > hx_on__before_on_load=None, hx_on__before_process_node=None, | |
| > hx_on__before_request=None, hx_on__before_swap=None, | |
| > hx_on__before_send=None, hx_on__before_transition=None, | |
| > hx_on__config_request=None, hx_on__confirm=None, | |
| > hx_on__history_cache_error=None, hx_on__history_cache_miss=None, | |
| > hx_on__history_cache_miss_error=None, | |
| > hx_on__history_cache_miss_load=None, hx_on__history_restore=None, | |
| > hx_on__before_history_save=None, hx_on__load=None, | |
| > hx_on__no_sse_source_error=None, hx_on__on_load_error=None, | |
| > hx_on__oob_after_swap=None, hx_on__oob_before_swap=None, | |
| > hx_on__oob_error_no_target=None, hx_on__prompt=None, | |
| > hx_on__pushed_into_history=None, hx_on__replaced_in_history=None, | |
| > hx_on__response_error=None, hx_on__send_abort=None, | |
| > hx_on__send_error=None, hx_on__sse_error=None, hx_on__sse_open=None, | |
| > hx_on__swap_error=None, hx_on__target_error=None, hx_on__timeout=None, | |
| > hx_on__validation_validate=None, hx_on__validation_failed=None, | |
| > hx_on__validation_halted=None, hx_on__xhr_abort=None, | |
| > hx_on__xhr_loadend=None, hx_on__xhr_loadstart=None, | |
| > hx_on__xhr_progress=None, **kwargs) | |
| *An A tag; `href` defaults to ‘\#’ for more concise use with HTMX* | |
| ``` python | |
| A('text', ht_get='/get', target_id='id') | |
| ``` | |
| ``` html | |
| <a href="#" ht-get="/get" hx-target="#id">text</a> | |
| ``` | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L32" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### AX | |
| > AX (txt, hx_get=None, target_id=None, hx_swap=None, href='#', | |
| > hx_vals=None, hx_target=None, id=None, cls=None, title=None, | |
| > style=None, accesskey=None, contenteditable=None, dir=None, | |
| > draggable=None, enterkeyhint=None, hidden=None, inert=None, | |
| > inputmode=None, lang=None, popover=None, spellcheck=None, | |
| > tabindex=None, translate=None, hx_post=None, hx_put=None, | |
| > hx_delete=None, hx_patch=None, hx_trigger=None, hx_swap_oob=None, | |
| > hx_include=None, hx_select=None, hx_select_oob=None, | |
| > hx_indicator=None, hx_push_url=None, hx_confirm=None, | |
| > hx_disable=None, hx_replace_url=None, hx_disabled_elt=None, | |
| > hx_ext=None, hx_headers=None, hx_history=None, hx_history_elt=None, | |
| > hx_inherit=None, hx_params=None, hx_preserve=None, hx_prompt=None, | |
| > hx_request=None, hx_sync=None, hx_validate=None, hx_on_blur=None, | |
| > hx_on_change=None, hx_on_contextmenu=None, hx_on_focus=None, | |
| > hx_on_input=None, hx_on_invalid=None, hx_on_reset=None, | |
| > hx_on_select=None, hx_on_submit=None, hx_on_keydown=None, | |
| > hx_on_keypress=None, hx_on_keyup=None, hx_on_click=None, | |
| > hx_on_dblclick=None, hx_on_mousedown=None, hx_on_mouseenter=None, | |
| > hx_on_mouseleave=None, hx_on_mousemove=None, hx_on_mouseout=None, | |
| > hx_on_mouseover=None, hx_on_mouseup=None, hx_on_wheel=None, | |
| > hx_on__abort=None, hx_on__after_on_load=None, | |
| > hx_on__after_process_node=None, hx_on__after_request=None, | |
| > hx_on__after_settle=None, hx_on__after_swap=None, | |
| > hx_on__before_cleanup_element=None, hx_on__before_on_load=None, | |
| > hx_on__before_process_node=None, hx_on__before_request=None, | |
| > hx_on__before_swap=None, hx_on__before_send=None, | |
| > hx_on__before_transition=None, hx_on__config_request=None, | |
| > hx_on__confirm=None, hx_on__history_cache_error=None, | |
| > hx_on__history_cache_miss=None, hx_on__history_cache_miss_error=None, | |
| > hx_on__history_cache_miss_load=None, hx_on__history_restore=None, | |
| > hx_on__before_history_save=None, hx_on__load=None, | |
| > hx_on__no_sse_source_error=None, hx_on__on_load_error=None, | |
| > hx_on__oob_after_swap=None, hx_on__oob_before_swap=None, | |
| > hx_on__oob_error_no_target=None, hx_on__prompt=None, | |
| > hx_on__pushed_into_history=None, hx_on__replaced_in_history=None, | |
| > hx_on__response_error=None, hx_on__send_abort=None, | |
| > hx_on__send_error=None, hx_on__sse_error=None, hx_on__sse_open=None, | |
| > hx_on__swap_error=None, hx_on__target_error=None, | |
| > hx_on__timeout=None, hx_on__validation_validate=None, | |
| > hx_on__validation_failed=None, hx_on__validation_halted=None, | |
| > hx_on__xhr_abort=None, hx_on__xhr_loadend=None, | |
| > hx_on__xhr_loadstart=None, hx_on__xhr_progress=None, **kwargs) | |
| *An A tag with just one text child, allowing hx_get, target_id, and | |
| hx_swap to be positional params* | |
| ``` python | |
| AX('text', '/get', 'id') | |
| ``` | |
| ``` html | |
| <a href="#" hx-get="/get" hx-target="#id">text</a> | |
| ``` | |
| ## Forms | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L38" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Form | |
| > Form (*c, enctype='multipart/form-data', target_id=None, hx_vals=None, | |
| > hx_target=None, id=None, cls=None, title=None, style=None, | |
| > accesskey=None, contenteditable=None, dir=None, draggable=None, | |
| > enterkeyhint=None, hidden=None, inert=None, inputmode=None, | |
| > lang=None, popover=None, spellcheck=None, tabindex=None, | |
| > translate=None, hx_get=None, hx_post=None, hx_put=None, | |
| > hx_delete=None, hx_patch=None, hx_trigger=None, hx_swap=None, | |
| > hx_swap_oob=None, hx_include=None, hx_select=None, | |
| > hx_select_oob=None, hx_indicator=None, hx_push_url=None, | |
| > hx_confirm=None, hx_disable=None, hx_replace_url=None, | |
| > hx_disabled_elt=None, hx_ext=None, hx_headers=None, | |
| > hx_history=None, hx_history_elt=None, hx_inherit=None, | |
| > hx_params=None, hx_preserve=None, hx_prompt=None, hx_request=None, | |
| > hx_sync=None, hx_validate=None, hx_on_blur=None, hx_on_change=None, | |
| > hx_on_contextmenu=None, hx_on_focus=None, hx_on_input=None, | |
| > hx_on_invalid=None, hx_on_reset=None, hx_on_select=None, | |
| > hx_on_submit=None, hx_on_keydown=None, hx_on_keypress=None, | |
| > hx_on_keyup=None, hx_on_click=None, hx_on_dblclick=None, | |
| > hx_on_mousedown=None, hx_on_mouseenter=None, hx_on_mouseleave=None, | |
| > hx_on_mousemove=None, hx_on_mouseout=None, hx_on_mouseover=None, | |
| > hx_on_mouseup=None, hx_on_wheel=None, hx_on__abort=None, | |
| > hx_on__after_on_load=None, hx_on__after_process_node=None, | |
| > hx_on__after_request=None, hx_on__after_settle=None, | |
| > hx_on__after_swap=None, hx_on__before_cleanup_element=None, | |
| > hx_on__before_on_load=None, hx_on__before_process_node=None, | |
| > hx_on__before_request=None, hx_on__before_swap=None, | |
| > hx_on__before_send=None, hx_on__before_transition=None, | |
| > hx_on__config_request=None, hx_on__confirm=None, | |
| > hx_on__history_cache_error=None, hx_on__history_cache_miss=None, | |
| > hx_on__history_cache_miss_error=None, | |
| > hx_on__history_cache_miss_load=None, hx_on__history_restore=None, | |
| > hx_on__before_history_save=None, hx_on__load=None, | |
| > hx_on__no_sse_source_error=None, hx_on__on_load_error=None, | |
| > hx_on__oob_after_swap=None, hx_on__oob_before_swap=None, | |
| > hx_on__oob_error_no_target=None, hx_on__prompt=None, | |
| > hx_on__pushed_into_history=None, hx_on__replaced_in_history=None, | |
| > hx_on__response_error=None, hx_on__send_abort=None, | |
| > hx_on__send_error=None, hx_on__sse_error=None, | |
| > hx_on__sse_open=None, hx_on__swap_error=None, | |
| > hx_on__target_error=None, hx_on__timeout=None, | |
| > hx_on__validation_validate=None, hx_on__validation_failed=None, | |
| > hx_on__validation_halted=None, hx_on__xhr_abort=None, | |
| > hx_on__xhr_loadend=None, hx_on__xhr_loadstart=None, | |
| > hx_on__xhr_progress=None, **kwargs) | |
| *A Form tag; identical to plain | |
| [`ft_hx`](https://www.fastht.ml/docs/api/components.html#ft_hx) version | |
| except default `enctype='multipart/form-data'`* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L44" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Hidden | |
| > Hidden (value:Any='', id:Any=None, target_id=None, hx_vals=None, | |
| > hx_target=None, cls=None, title=None, style=None, accesskey=None, | |
| > contenteditable=None, dir=None, draggable=None, | |
| > enterkeyhint=None, hidden=None, inert=None, inputmode=None, | |
| > lang=None, popover=None, spellcheck=None, tabindex=None, | |
| > translate=None, hx_get=None, hx_post=None, hx_put=None, | |
| > hx_delete=None, hx_patch=None, hx_trigger=None, hx_swap=None, | |
| > hx_swap_oob=None, hx_include=None, hx_select=None, | |
| > hx_select_oob=None, hx_indicator=None, hx_push_url=None, | |
| > hx_confirm=None, hx_disable=None, hx_replace_url=None, | |
| > hx_disabled_elt=None, hx_ext=None, hx_headers=None, | |
| > hx_history=None, hx_history_elt=None, hx_inherit=None, | |
| > hx_params=None, hx_preserve=None, hx_prompt=None, | |
| > hx_request=None, hx_sync=None, hx_validate=None, hx_on_blur=None, | |
| > hx_on_change=None, hx_on_contextmenu=None, hx_on_focus=None, | |
| > hx_on_input=None, hx_on_invalid=None, hx_on_reset=None, | |
| > hx_on_select=None, hx_on_submit=None, hx_on_keydown=None, | |
| > hx_on_keypress=None, hx_on_keyup=None, hx_on_click=None, | |
| > hx_on_dblclick=None, hx_on_mousedown=None, hx_on_mouseenter=None, | |
| > hx_on_mouseleave=None, hx_on_mousemove=None, hx_on_mouseout=None, | |
| > hx_on_mouseover=None, hx_on_mouseup=None, hx_on_wheel=None, | |
| > hx_on__abort=None, hx_on__after_on_load=None, | |
| > hx_on__after_process_node=None, hx_on__after_request=None, | |
| > hx_on__after_settle=None, hx_on__after_swap=None, | |
| > hx_on__before_cleanup_element=None, hx_on__before_on_load=None, | |
| > hx_on__before_process_node=None, hx_on__before_request=None, | |
| > hx_on__before_swap=None, hx_on__before_send=None, | |
| > hx_on__before_transition=None, hx_on__config_request=None, | |
| > hx_on__confirm=None, hx_on__history_cache_error=None, | |
| > hx_on__history_cache_miss=None, | |
| > hx_on__history_cache_miss_error=None, | |
| > hx_on__history_cache_miss_load=None, hx_on__history_restore=None, | |
| > hx_on__before_history_save=None, hx_on__load=None, | |
| > hx_on__no_sse_source_error=None, hx_on__on_load_error=None, | |
| > hx_on__oob_after_swap=None, hx_on__oob_before_swap=None, | |
| > hx_on__oob_error_no_target=None, hx_on__prompt=None, | |
| > hx_on__pushed_into_history=None, hx_on__replaced_in_history=None, | |
| > hx_on__response_error=None, hx_on__send_abort=None, | |
| > hx_on__send_error=None, hx_on__sse_error=None, | |
| > hx_on__sse_open=None, hx_on__swap_error=None, | |
| > hx_on__target_error=None, hx_on__timeout=None, | |
| > hx_on__validation_validate=None, hx_on__validation_failed=None, | |
| > hx_on__validation_halted=None, hx_on__xhr_abort=None, | |
| > hx_on__xhr_loadend=None, hx_on__xhr_loadstart=None, | |
| > hx_on__xhr_progress=None, **kwargs) | |
| *An Input of type ‘hidden’* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L50" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### CheckboxX | |
| > CheckboxX (checked:bool=False, label=None, value='1', id=None, name=None, | |
| > target_id=None, hx_vals=None, hx_target=None, cls=None, | |
| > title=None, style=None, accesskey=None, contenteditable=None, | |
| > dir=None, draggable=None, enterkeyhint=None, hidden=None, | |
| > inert=None, inputmode=None, lang=None, popover=None, | |
| > spellcheck=None, tabindex=None, translate=None, hx_get=None, | |
| > hx_post=None, hx_put=None, hx_delete=None, hx_patch=None, | |
| > hx_trigger=None, hx_swap=None, hx_swap_oob=None, | |
| > hx_include=None, hx_select=None, hx_select_oob=None, | |
| > hx_indicator=None, hx_push_url=None, hx_confirm=None, | |
| > hx_disable=None, hx_replace_url=None, hx_disabled_elt=None, | |
| > hx_ext=None, hx_headers=None, hx_history=None, | |
| > hx_history_elt=None, hx_inherit=None, hx_params=None, | |
| > hx_preserve=None, hx_prompt=None, hx_request=None, | |
| > hx_sync=None, hx_validate=None, hx_on_blur=None, | |
| > hx_on_change=None, hx_on_contextmenu=None, hx_on_focus=None, | |
| > hx_on_input=None, hx_on_invalid=None, hx_on_reset=None, | |
| > hx_on_select=None, hx_on_submit=None, hx_on_keydown=None, | |
| > hx_on_keypress=None, hx_on_keyup=None, hx_on_click=None, | |
| > hx_on_dblclick=None, hx_on_mousedown=None, | |
| > hx_on_mouseenter=None, hx_on_mouseleave=None, | |
| > hx_on_mousemove=None, hx_on_mouseout=None, | |
| > hx_on_mouseover=None, hx_on_mouseup=None, hx_on_wheel=None, | |
| > hx_on__abort=None, hx_on__after_on_load=None, | |
| > hx_on__after_process_node=None, hx_on__after_request=None, | |
| > hx_on__after_settle=None, hx_on__after_swap=None, | |
| > hx_on__before_cleanup_element=None, | |
| > hx_on__before_on_load=None, hx_on__before_process_node=None, | |
| > hx_on__before_request=None, hx_on__before_swap=None, | |
| > hx_on__before_send=None, hx_on__before_transition=None, | |
| > hx_on__config_request=None, hx_on__confirm=None, | |
| > hx_on__history_cache_error=None, | |
| > hx_on__history_cache_miss=None, | |
| > hx_on__history_cache_miss_error=None, | |
| > hx_on__history_cache_miss_load=None, | |
| > hx_on__history_restore=None, hx_on__before_history_save=None, | |
| > hx_on__load=None, hx_on__no_sse_source_error=None, | |
| > hx_on__on_load_error=None, hx_on__oob_after_swap=None, | |
| > hx_on__oob_before_swap=None, hx_on__oob_error_no_target=None, | |
| > hx_on__prompt=None, hx_on__pushed_into_history=None, | |
| > hx_on__replaced_in_history=None, hx_on__response_error=None, | |
| > hx_on__send_abort=None, hx_on__send_error=None, | |
| > hx_on__sse_error=None, hx_on__sse_open=None, | |
| > hx_on__swap_error=None, hx_on__target_error=None, | |
| > hx_on__timeout=None, hx_on__validation_validate=None, | |
| > hx_on__validation_failed=None, hx_on__validation_halted=None, | |
| > hx_on__xhr_abort=None, hx_on__xhr_loadend=None, | |
| > hx_on__xhr_loadstart=None, hx_on__xhr_progress=None, **kwargs) | |
| *A Checkbox optionally inside a Label, preceded by a | |
| [`Hidden`](https://www.fastht.ml/docs/api/xtend.html#hidden) with | |
| matching name* | |
| ``` python | |
| show(CheckboxX(True, 'Check me out!')) | |
| ``` | |
| <input type="hidden" skip> | |
| <label> <input type="checkbox" checked value="1"> | |
| Check me out!</label> | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L60" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Script | |
| > Script (code:str='', id=None, cls=None, title=None, style=None, | |
| > attrmap=None, valmap=None, ft_cls=None, **kwargs) | |
| *A Script tag that doesn’t escape its code* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L66" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Style | |
| > Style (*c, id=None, cls=None, title=None, style=None, attrmap=None, | |
| > valmap=None, ft_cls=None, **kwargs) | |
| *A Style tag that doesn’t escape its code* | |
| ## Style and script templates | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L71" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### double_braces | |
| > double_braces (s) | |
| *Convert single braces to double braces if next to special chars or | |
| newline* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L77" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### undouble_braces | |
| > undouble_braces (s) | |
| *Convert double braces to single braces if next to special chars or | |
| newline* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L83" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### loose_format | |
| > loose_format (s, **kw) | |
| *String format `s` using `kw`, without being strict about braces outside | |
| of template params* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L89" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### ScriptX | |
| > ScriptX (fname, src=None, nomodule=None, type=None, _async=None, | |
| > defer=None, charset=None, crossorigin=None, integrity=None, | |
| > **kw) | |
| *A `script` element with contents read from `fname`* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L97" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### replace_css_vars | |
| > replace_css_vars (css, pre='tpl', **kwargs) | |
| *Replace `var(--)` CSS variables with `kwargs` if name prefix matches | |
| `pre`* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L106" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### StyleX | |
| > StyleX (fname, **kw) | |
| *A `style` element with contents read from `fname` and variables | |
| replaced from `kw`* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L114" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Nbsp | |
| > Nbsp () | |
| *A non-breaking space* | |
| ## Surreal and JS | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L119" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Surreal | |
| > Surreal (code:str) | |
| *Wrap `code` in `domReadyExecute` and set `m=me()` and `p=me('-')`* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L132" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### On | |
| > On (code:str, event:str='click', sel:str='', me=True) | |
| *An async surreal.js script block event handler for `event` on selector | |
| `sel,p`, making available parent `p`, event `ev`, and target `e`* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L145" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Prev | |
| > Prev (code:str, event:str='click') | |
| *An async surreal.js script block event handler for `event` on previous | |
| sibling, with same vars as | |
| [`On`](https://www.fastht.ml/docs/api/xtend.html#on)* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L150" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Now | |
| > Now (code:str, sel:str='') | |
| *An async surreal.js script block on selector `me(sel)`* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L156" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### AnyNow | |
| > AnyNow (sel:str, code:str) | |
| *An async surreal.js script block on selector `any(sel)`* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L161" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### run_js | |
| > run_js (js, id=None, **kw) | |
| *Run `js` script, auto-generating `id` based on name of caller if | |
| needed, and js-escaping any `kw` params* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L168" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### HtmxOn | |
| > HtmxOn (eventname:str, code:str) | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L174" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### jsd | |
| > jsd (org, repo, root, path, prov='gh', typ='script', ver=None, esm=False, | |
| > **kwargs) | |
| *jsdelivr [`Script`](https://www.fastht.ml/docs/api/xtend.html#script) | |
| or CSS `Link` tag, or URL* | |
| ## Other helpers | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L182" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Fragment | |
| > Fragment (*c) | |
| *An empty tag, used as a container* | |
| ``` python | |
| fts = Fragment(P('1st'), P('2nd')) | |
| print(to_xml(fts)) | |
| ``` | |
| <p>1st</p> | |
| <p>2nd</p> | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L188" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Titled | |
| > Titled (title:str='FastHTML app', *args, cls='container', target_id=None, | |
| > hx_vals=None, hx_target=None, id=None, style=None, | |
| > accesskey=None, contenteditable=None, dir=None, draggable=None, | |
| > enterkeyhint=None, hidden=None, inert=None, inputmode=None, | |
| > lang=None, popover=None, spellcheck=None, tabindex=None, | |
| > translate=None, hx_get=None, hx_post=None, hx_put=None, | |
| > hx_delete=None, hx_patch=None, hx_trigger=None, hx_swap=None, | |
| > hx_swap_oob=None, hx_include=None, hx_select=None, | |
| > hx_select_oob=None, hx_indicator=None, hx_push_url=None, | |
| > hx_confirm=None, hx_disable=None, hx_replace_url=None, | |
| > hx_disabled_elt=None, hx_ext=None, hx_headers=None, | |
| > hx_history=None, hx_history_elt=None, hx_inherit=None, | |
| > hx_params=None, hx_preserve=None, hx_prompt=None, | |
| > hx_request=None, hx_sync=None, hx_validate=None, hx_on_blur=None, | |
| > hx_on_change=None, hx_on_contextmenu=None, hx_on_focus=None, | |
| > hx_on_input=None, hx_on_invalid=None, hx_on_reset=None, | |
| > hx_on_select=None, hx_on_submit=None, hx_on_keydown=None, | |
| > hx_on_keypress=None, hx_on_keyup=None, hx_on_click=None, | |
| > hx_on_dblclick=None, hx_on_mousedown=None, hx_on_mouseenter=None, | |
| > hx_on_mouseleave=None, hx_on_mousemove=None, hx_on_mouseout=None, | |
| > hx_on_mouseover=None, hx_on_mouseup=None, hx_on_wheel=None, | |
| > hx_on__abort=None, hx_on__after_on_load=None, | |
| > hx_on__after_process_node=None, hx_on__after_request=None, | |
| > hx_on__after_settle=None, hx_on__after_swap=None, | |
| > hx_on__before_cleanup_element=None, hx_on__before_on_load=None, | |
| > hx_on__before_process_node=None, hx_on__before_request=None, | |
| > hx_on__before_swap=None, hx_on__before_send=None, | |
| > hx_on__before_transition=None, hx_on__config_request=None, | |
| > hx_on__confirm=None, hx_on__history_cache_error=None, | |
| > hx_on__history_cache_miss=None, | |
| > hx_on__history_cache_miss_error=None, | |
| > hx_on__history_cache_miss_load=None, hx_on__history_restore=None, | |
| > hx_on__before_history_save=None, hx_on__load=None, | |
| > hx_on__no_sse_source_error=None, hx_on__on_load_error=None, | |
| > hx_on__oob_after_swap=None, hx_on__oob_before_swap=None, | |
| > hx_on__oob_error_no_target=None, hx_on__prompt=None, | |
| > hx_on__pushed_into_history=None, hx_on__replaced_in_history=None, | |
| > hx_on__response_error=None, hx_on__send_abort=None, | |
| > hx_on__send_error=None, hx_on__sse_error=None, | |
| > hx_on__sse_open=None, hx_on__swap_error=None, | |
| > hx_on__target_error=None, hx_on__timeout=None, | |
| > hx_on__validation_validate=None, hx_on__validation_failed=None, | |
| > hx_on__validation_halted=None, hx_on__xhr_abort=None, | |
| > hx_on__xhr_loadend=None, hx_on__xhr_loadstart=None, | |
| > hx_on__xhr_progress=None, **kwargs) | |
| *An HTML partial containing a `Title`, and `H1`, and any provided | |
| children* | |
| ``` python | |
| show(Titled('my page', P('para'))) | |
| ``` | |
| <title>my page</title> | |
| <main class="container"> <h1>my page</h1> | |
| <p>para</p> | |
| </main> | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L193" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Socials | |
| > Socials (title, site_name, description, image, url=None, w=1200, h=630, | |
| > twitter_site=None, creator=None, card='summary') | |
| *OG and Twitter social card headers* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L216" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### YouTubeEmbed | |
| > YouTubeEmbed (video_id:str, width:int=560, height:int=315, | |
| > start_time:int=0, no_controls:bool=False, | |
| > title:str='YouTube video player', cls:str='', **kwargs) | |
| *Embed a YouTube video* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L241" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### Favicon | |
| > Favicon (light_icon, dark_icon) | |
| *Light and dark favicon headers* | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L247" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### clear | |
| > clear (id) | |
| ------------------------------------------------------------------------ | |
| <a | |
| href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/xtend.py#L268" | |
| target="_blank" style="float:right; font-size:smaller">source</a> | |
| ### with_sid | |
| > with_sid (app, dest, path='/') | |