gin
gin copied to clipboard
No way to manually render a template on the fly
Description
LoadHTMLFiles()
is awesome and anything, but it'd be really nice to have an exposed API to manually render templates which haven't been loaded as ones.
I explain myself better: point is that the current API only allows HTML files to be rendered as templates when previously loaded and, more importantly, only if HTML files are effectively files.
In my use case, HTML files are actually calculated on the fly (taken from a packr.Box
and manipulated in some ways, e.g., minified), so the LoadHTMLFiles()
endpoint is really not applicable and usable in any way.
I tried looking aroung to see if there's any exposed way to render the templates (the same way they are within the LoadHTMLFiles()
method) but it seems there's not. If I'm wrong, feel free to walk me to the right direction.
How to reproduce
Not applicable, just a proposal.
Expectations
Something like func (c *Context) RenderHTML(code int, data []byte, obj interface{})
, where data
is containing the template itself, loaded and rendered on the fly.
Actual result
Still read above.
Environment
Still not applicable.
@streambinder Is there a solution to this problem?
As far as I know, currently not.
I actually want to just render a template into a normal string and then do something else with it besides render it back to the client; I'm not able to do that because when I look at the current context definition we don't even support export the engine because it's not currently capitalized.
If we had access to the render engine of the call via the context, that would open up a lot of possibilities.