hairyhenderson/gomplate

Need to finalize gomplate.Renderer and related types before v4.0.0

jlambert121 opened this issue · 2 comments

It looks like the public interface for using gomplete is in flux as it is moved to version 4 so this is likely a "it's not quite done yet" question.

The deprecated RunTemplates supports passing in InputDir and OutputDir which is super convenient when processing a directory since it builds the list of templates before calling the new gomplate.Renderer#RenderTemplates. This appears to be currently broken on gatherTemplates when cfg.InputDir != "" since the FSProvider is unset on the context.

Is the intent to have something similar to RunTemplates (or Run) with the new Renderer or should I enumerate the list of templates myself and provide it to RenderTemplates?

In concept Run replaces the deprecated RunTemplates function, but the Config type is still internal so it's not usable yet - that's the main thing blocking the v4.0.0 release, actually.

Another way to approach this that should work (?) is to use Renderer and handle the directory reading logic yourself. But keep in mind that it will likely change before v4.0.0 (NewRenderer is especially awkward to use right now as the Options type contains members that are actually non-optional)

If you don't mind I'm going to rename this issue and use it to track finalizing gomplate.Renderer before v4.0 😅

If Run is intended to be the replacement for RunTemplates, works for me - does exactly what I'm looking for! It currently breaks down here though since ctx is missing fsProviderCtxKey (ultimately in datafs.ResolveLocalPath).

RenderTemplates solves this, but that's too late for Run. Happy to take a stab at a PR, just not quite sure what direction to take for this.