News for hackers. Stuff that matters.
Re:Hyper – A fast and correct HTTP implementation for Rust by infogulch on Friday May 12, 2023 @06:20PM (#35923223)
Sure. They're called 'partials' sometimes. Useful if you want to rerender just part of a page. This is a pattern used by HTMX, a 'js framework' that accepts fragments of html in an http response and injects it into the page. This is good because it avoids the flash and state loss of a whole page reload. See the HTMX essay on template fragments for a more complete argument [0].

This is a go template for an interactive todos app [1] that I'm experimenting with. The html content of the entire page is present in one template definition which is split into 6 inline {{block}} definitions / "fragments". The page supports 5 interactions indicated by {{define}} definitions, each of which reuse various block fragments relevant to that interaction. I'm in the process of converting it to use embedded cozodb [2] queries which act as a server side data store. The idea here is that the entire 'app', including all html fragments, styles, http requests and responses, db schema, and queries are embedded into this single 100-line file.

[0]: https://htmx.org/essays/template-fragments/

[1]: https://github.com/infogulch/go-htmx/blob/master/templates/t...

[2]: https://github.com/cozodb/cozo

Re:Hyper – A fast and correct HTTP implementation for Rust by langfan on Friday May 12, 2023 @07:05PM (#35923633)
>Sure. They're called 'partials' sometimes.

Same as partials in Rails, maybe. A while since I used it.