def render_breadcrumbs( current_path:str, # Current directory path navigate_url:str, # URL for navigation hx_target:Optional=None, # HTMX target for swaps max_segments:int=5, # Max segments to show (0 = all) breadcrumbs_id:Optional=None, # HTML ID for breadcrumbs)->Any: # Breadcrumbs component
Render path as breadcrumb navigation.
from fasthtml.common import to_xml# Test breadcrumbsbc = render_breadcrumbs("/home/user/Documents", "/navigate")html = to_xml(bc)assert"Root"in html # / becomes Rootassert"home"in htmlassert"user"in htmlassert"Documents"in htmlassert"breadcrumbs"in html# Test with HTMX targetbc = render_breadcrumbs("/home/user", "/nav", hx_target="#browser")html = to_xml(bc)assert"hx-target"in htmlassert"#browser"in htmlprint("Breadcrumbs tests passed!")
def render_path_input( current_path:str, # Current path to display navigate_url:str, # URL for navigation hx_target:Optional=None, # HTMX target for swaps input_id:Optional=None, # HTML ID for input)->Any: # Path input component