Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to manually render a template on the fly #2855

Open
streambinder opened this issue Sep 3, 2021 · 3 comments
Open

No way to manually render a template on the fly #2855

streambinder opened this issue Sep 3, 2021 · 3 comments

Comments

@streambinder
Copy link

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.

@gswy
Copy link

gswy commented May 6, 2022

@streambinder Is there a solution to this problem?

@streambinder
Copy link
Author

As far as I know, currently not.

@duaneking
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants