Add "Static" func#325
Conversation
markuswustenberg
left a comment
There was a problem hiding this comment.
Let's discuss the implementation details a bit more, if you're up for it. :-)
If you'd rather not, feel free to let me know, and we can merge and I'll iterate myself.
| staticHead := g.Static(h.Head( | ||
| h.TitleEl(g.Text("My site")), | ||
| h.Link(h.Rel("stylesheet"), h.Href("/app.css")), | ||
| )) |
There was a problem hiding this comment.
I've been thinking a bit about the usage of this. It's a shame you lose the ability to inline the Static component like you usually would with all the other components, and that you have to keep the node variable (staticHead here) somewhere as state between requests.
Would it be nicer to perhaps pass a string pointer or something, that the receiving function renders to if non-empty? And subsequent requests see the non-empty pointer value and just use that.
| - `Map` for mapping data to components and `Group` for grouping components, | ||
| - and `If`/`Iff` for conditional rendering. | ||
| - `If`/`Iff` for conditional rendering, | ||
| - and `Static` for caching large static element trees. |
There was a problem hiding this comment.
I definitely rather want this in the components package, like the other specialized helpers there. I don't see it as a low-level primitive. Could you move it there?
|
Hey @markuswustenberg ! there will probably be lots of back and forth, and this pr requires more taste than tedious work really. The code by itself is very small. Feel free to merge this / close this pr and implement it the way you want it. I thought more about the global key val cache that you proposed, could be another interesting approach, I might have overrated the complexity. |
|
Okay, thank you for the reply and your work so far. I'll try some stuff out when I have some spare time. :-) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #325 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 633 647 +14
=========================================
+ Hits 633 647 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
As discussed here #323 , here's the Static implementation.
@markuswustenberg I did add the static func at "gomponents.go". It feels enough of a primitive to be there I think?