You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tested my example against Shopify Liquid. (This isn't necessary if the actual behavior is a panic, or an error for which IsTemplateError returns false.)
Expected Behavior
This proposal originated from #35 but tries to tackle a broader issue, i.e.: Sometimes I might want to have more control over the rendering process, specifically where the renderer writes to.
Example
I might want to limit the number of bytes written when exposing templating to some untrusted party.
I might want to set a timeout for the rendering process.
I might want to render into a file directly.
Actual Behavior
The render package has a Render(node Node, w io.Writer, vars map[string]interface{}, c Config) function which takes an io.Writer, however, this is meant for internal use only. The Template methods have Render(vars Bindings) ([]byte, SourceError) and RenderString(b Bindings) (string, SourceError) which are useful in most circumstances but don't allow for more control as described above.
Detailed Description
Possible Solution
I'd propose a new Template render method FRender that allows to pass a custom io.Writer:
func (t *Template) FRender(w io.Writer, vars Bindings) SourceError
This gives more control over the rendering process when needed, e.g. you might want to set a render timeout to avoid deeple nested loop constructs in a template to cause potential server issues:
Checklist
IsTemplateError
returns false.)Expected Behavior
This proposal originated from #35 but tries to tackle a broader issue, i.e.: Sometimes I might want to have more control over the rendering process, specifically where the renderer writes to.
Example
Actual Behavior
The
render
package has aRender(node Node, w io.Writer, vars map[string]interface{}, c Config)
function which takes anio.Writer
, however, this is meant for internal use only. TheTemplate
methods haveRender(vars Bindings) ([]byte, SourceError)
andRenderString(b Bindings) (string, SourceError)
which are useful in most circumstances but don't allow for more control as described above.Detailed Description
Possible Solution
I'd propose a new
Template
render methodFRender
that allows to pass a customio.Writer
:This gives more control over the rendering process when needed, e.g. you might want to set a render timeout to avoid deeple nested loop constructs in a template to cause potential server issues:
The text was updated successfully, but these errors were encountered: