Documentation
¶
Overview ¶
Custom dot provider example: the "repository pattern". A custom provider exposes hardcoded in-memory data to templates as {{.Shop}}, which can range over products and look one up by id.
To write a dot provider: implement xtemplate.Provider (FieldName, Prototype, Value), then register a factory with xtemplate.WithProvider passed to app.Main. FieldName is the dot field name; Prototype is a typed zero value for reflection; Value returns the value assigned to that field for each request. Init is optional (Initializer).
Click to show internal directories.
Click to hide internal directories.