Better templating system
The current templating system from !1 (merged) isn't the best. I wrote it without a solid grasp on go's scoping, so it unnecessarily loads templates from disk on every request and passes around closures to keep scope. The rendered lektor templates also use printf-formatting which works fine for the templates as they are now, but it's pretty fragile.
A big issue with the old system was that any error in the handler functions would call SendError
. SendError
couldn't be use a template, because the error might actually be related to loading templates. Loading the templates at startup eliminates that issue, so now SendError
can use a proper template instead of sending the error string wrapped in <h1>
tags.
I'm currently rewriting the templating with html/template syntax, and I've reworked the code to only load the templates from disk once, into a global map so closures aren't needed (it looks a lot nicer too!)