16 lines
703 B
Python
16 lines
703 B
Python
import html as html_lib
|
|
|
|
from .visible_attrs import _visible_attrs
|
|
from .apply_ctx import _apply_ctx
|
|
from .style_string import _style_string
|
|
from .attr_string import _attr_string
|
|
|
|
|
|
def _render_select(el, meta, slug=None, children_map=None, ctx=None, parent_flex_direction=None):
|
|
attrs = _visible_attrs(el, meta, ctx)
|
|
style = _style_string(el, parent_flex_direction=parent_flex_direction)
|
|
content = _apply_ctx(el.get("content") or "", ctx)
|
|
options = [o.strip() for o in content.split("\n") if o.strip()]
|
|
opts_html = "".join(f'<option value="{html_lib.escape(o)}">{html_lib.escape(o)}</option>' for o in options)
|
|
return f'<select {_attr_string(attrs, style)}>{opts_html}</select>'
|