Show HN: Htpy – generate HTML from Python without templates
htpy.dev
Show HN: Htpy – generate HTML from Python without templates
1–3 of 3 posts
Re: Show HN: Htpy – generate HTML from Python without templates
#2> Wrapping Bootstrap Modal could be achieved with a function like this:
def bootstrap_modal(*, title: str, body: Node = None, footer: Node = None) ->
Element:
return div(".modal", tabindex="-1", role="dialog")[
div(".modal-dialog", role="document")[
div(".modal-content")[
div(".modal-header")[
div(".modal-title")[
h5(".modal-title")[title],
button(
".close",
type="button",
data_dismiss="modal",
aria_label="Close",
)[span(aria_hidden="true")[Markup("×")]],
]
],
div(".modal-body")[body],
footer and div(".modal-footer")[footer],
]
]
]Re: Show HN: Htpy – generate HTML from Python without templates
#3Is that really easier than using templates? > Wrapping Bootstrap Modal could be achieved with a function like this: def bootstrap_modal(*, title: str, body: Node = None, footer: Node = None) -> Element: return div(".modal", tabindex="-1", role="dialog")[ div(".modal-dialog", role="document")[ div(".modal-content")[ div(".modal-header")[ div(".modal-title")[ h5(".modal-title")[title], button( ".close", type="button",…
The real benefit is using this bootstrap modal component within your app, since it is just a regular function call. You can leverage your editor "goto definition" and static type checking within all the functions make up your web sites/apps HTML.