Documentation
¶
Overview ¶
Package template discovers, parses, and renders user-supplied Go templates against a sqlc GenerateRequest.
Index ¶
Constants ¶
const Extension = ".tmpl"
Extension is the required suffix for template files discovered under the configured templates directory.
const PartialPrefix = "_"
PartialPrefix marks template files that are parsed but not emitted as standalone outputs; they exist to be {{ template "_foo" . }}-included.
Variables ¶
This section is empty.
Functions ¶
func FuncMap ¶
FuncMap returns the template function map used by Render. Each call produces a fresh FuncMap because setStore/getStore close over a per-render map so cross-render state never leaks.
func Render ¶
Render walks ctx.TemplateDir for *.tmpl files, parses them all into a shared template set (so cross-file {{ template }} includes work), then executes every non-partial template against ctx. Output filenames are the template's path relative to TemplateDir, minus the .tmpl suffix, with the resulting string itself executed as a template.
Types ¶
type Context ¶
type Context struct {
// Request is the raw sqlc GenerateRequest.
Request *plugin.GenerateRequest
// Options carries the user-supplied free-form extra map from sqlc.yaml.
Options map[string]any
// TemplateDir is the absolute or sqlc-relative directory that was
// walked to discover templates. Exposed to templates for reference.
TemplateDir string
// SqlcVersion is hoisted from Request.SqlcVersion for convenience.
SqlcVersion string
}
Context is the root value ('.') handed to every template and also used to render output-file names.