Open joeyak opened 5 years ago
I thought I had a TODO for this somewhere.
But yes, ideally that stuff should be a template somewhere that's loaded once at the server start. Maybe a global, read-only, map[string]html.Template
? Where the string is the use of the template, eg "MsgAction" or "EvBan".
I like the map[string]html.Template
idea. The keys should be "enum" constants. Maybe with a Tmpl
prefix.
This just occurred to me, but the templates cannot just be loaded into the server. They need to be sent to the wasm client, as that's what actually calls .HTML()
on the data.
But now that we have some more robust communication between the client and server, this shouldn't pose much of a problem.
Were you thinking of having the templates loaded on server start? I was thinking of making the templates "contasts", but I think I might like the load at runtime better.
Yea, on server start. I think I'd like to handle it similarly to how emotes are loaded. Once on server start, but they can be refreshed by an admin with a command.
Refreshing shouldn't update HTML that's already been displayed, only new HTML. Comparing it to emotes again, when emotes are refreshed and new ones are found, old messages are not re-parsed for the new emote.
It would be better to have a specific spot to store all the html message templates. Perhaps a slice or constants in another file.