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
While trying to implement a new template type on stream, BG ran into a number of issues; however, one of the biggest (and easiest to target) was the amount of coordination there is to do around the codebase to implement a set of templates.
We need something better from a DevEx perspective that makes these easier to do.
I'm thinking something along these lines (pseudocode):
typeTemplateParametersinterface {
// FillDefaults populates the params struct with default values.FillDefaults()
}
// Template represents a renderable templatetypeTemplate[Tany] struct {
templates templates.RenderMap
}
// Render renders the template files out to the current directoryfunc (tTemplate) Render() error {
// Logic used to write templates for _every_ template type.
}
// -------------------------typeGoLambdaParametersstruct {
NixNixConfig`json:"nix" yaml:"nix"`
}
func (pGoLambdaParameters) FillDefaults() {
p.Nix=NewNixConfig()
}
// -------------------------varTemplates=map[string]Template[TemplateParameters]{
"go-lambda": Template[GoLambdaParameters]{
templates: templates.RenderMap{
templates.GoCommonTemplates{".editorconfig"},
templates.GoLambdaTemplates{".github/workflows/flake.yaml"},
},
},
}
funcmain() {
t:=Templates["go-lambda"]
iferr:=t.Render(); err!=nil {
fmt.Fprintf(os.Stderr, "Failed to render template '%v': %v", t.name, err)
os.Exit(1)
}
}
What this pseudocode doesn't cover is finding a better way to implement loading in the templates; maybe we can pass in a template path as part of the TemplateMap type or similar that will load them dynamically during the Render() procedure.
The text was updated successfully, but these errors were encountered:
While trying to implement a new template type on stream, BG ran into a number of issues; however, one of the biggest (and easiest to target) was the amount of coordination there is to do around the codebase to implement a set of templates.
We need something better from a DevEx perspective that makes these easier to do.
I'm thinking something along these lines (pseudocode):
What this pseudocode doesn't cover is finding a better way to implement loading in the templates; maybe we can pass in a template path as part of the TemplateMap type or similar that will load them dynamically during the
Render()
procedure.The text was updated successfully, but these errors were encountered: