Documentation
¶
Index ¶
- Variables
- func ClearCache()
- func GetCachedTemplate(templateName string, funcMap template.FuncMap) (*template.Template, error)
- func RenderTemplateUsingGlobal(templateName string, data any) (string, error)
- type DatabaseData
- type ProjectData
- type ResourceData
- type TemplateBuilder
- func (tb *TemplateBuilder) Render(templateName string) (string, error)
- func (tb *TemplateBuilder) WithCustom(key string, value any) *TemplateBuilder
- func (tb *TemplateBuilder) WithDatabase(dbType, method, driver string) *TemplateBuilder
- func (tb *TemplateBuilder) WithProject(modulePath, name string) *TemplateBuilder
- func (tb *TemplateBuilder) WithResource(name, pluralName, modulePath, resourceType, databaseType string, fields any) *TemplateBuilder
- type TemplateCache
- type TemplateData
- type TemplateService
- func (ts *TemplateService) RenderTemplate(templateName string, data any) (string, error)
- func (ts *TemplateService) RenderTemplateWithCustomFunctions(templateName string, data any, funcMap template.FuncMap) (string, error)
- func (ts *TemplateService) RenderTemplateWithCustomFunctionsAndPartials(templateName string, partialNames []string, data any, funcMap template.FuncMap) (string, error)
Constants ¶
This section is empty.
Variables ¶
var Files embed.FS
Functions ¶
func GetCachedTemplate ¶
GetCachedTemplate returns cached template.
Types ¶
type DatabaseData ¶
type DatabaseData struct {
Type string `json:"type"`
Method string `json:"method"`
Driver string `json:"driver"`
}
DatabaseData contains database-specific template data
type ProjectData ¶
ProjectData contains project-specific template data
type ResourceData ¶
type ResourceData struct {
Name string `json:"name"`
PluralName string `json:"plural_name"`
Fields any `json:"fields"`
ModulePath string `json:"module_path"`
Type string `json:"type"`
DatabaseType string `json:"database_type"`
}
ResourceData contains resource-specific template data
type TemplateBuilder ¶
type TemplateBuilder struct {
// contains filtered or unexported fields
}
TemplateBuilder provides a fluent interface for building template data
func NewTemplateBuilder ¶
func NewTemplateBuilder(service *TemplateService) *TemplateBuilder
NewTemplateBuilder creates a new template builder
func NewTemplateBuilderUsingGlobal ¶
func NewTemplateBuilderUsingGlobal() *TemplateBuilder
NewTemplateBuilderUsingGlobal creates a new template builder using the global service
func (*TemplateBuilder) Render ¶
func (tb *TemplateBuilder) Render(templateName string) (string, error)
Render renders the template with the built data
func (*TemplateBuilder) WithCustom ¶
func (tb *TemplateBuilder) WithCustom(key string, value any) *TemplateBuilder
WithCustom adds custom data
func (*TemplateBuilder) WithDatabase ¶
func (tb *TemplateBuilder) WithDatabase(dbType, method, driver string) *TemplateBuilder
WithDatabase sets database data
func (*TemplateBuilder) WithProject ¶
func (tb *TemplateBuilder) WithProject(modulePath, name string) *TemplateBuilder
WithProject sets project data
func (*TemplateBuilder) WithResource ¶
func (tb *TemplateBuilder) WithResource( name, pluralName, modulePath, resourceType, databaseType string, fields any, ) *TemplateBuilder
WithResource sets resource data
type TemplateCache ¶
type TemplateCache struct {
// contains filtered or unexported fields
}
TemplateCache represents template cache.
func NewTemplateCache ¶
func NewTemplateCache() *TemplateCache
NewTemplateCache creates a new template cache.
func (*TemplateCache) GetTemplate ¶
func (tc *TemplateCache) GetTemplate( templateName string, funcMap template.FuncMap, ) (*template.Template, error)
GetTemplate returns template.
type TemplateData ¶
type TemplateData struct {
Resource ResourceData `json:"resource"`
Database DatabaseData `json:"database"`
Project ProjectData `json:"project"`
Custom map[string]any `json:"custom"`
}
TemplateData represents the unified data structure for all templates
type TemplateService ¶
type TemplateService struct {
// contains filtered or unexported fields
}
TemplateService provides unified template rendering functionality
func GetGlobalTemplateService ¶
func GetGlobalTemplateService() *TemplateService
GetGlobalTemplateService returns the global template service instance
func NewTemplateService ¶
func NewTemplateService() *TemplateService
NewTemplateService creates a new template service with default functions
func (*TemplateService) RenderTemplate ¶
func (ts *TemplateService) RenderTemplate(templateName string, data any) (string, error)
RenderTemplate renders a template with the given data
func (*TemplateService) RenderTemplateWithCustomFunctions ¶
func (ts *TemplateService) RenderTemplateWithCustomFunctions( templateName string, data any, funcMap template.FuncMap, ) (string, error)
RenderTemplateWithCustomFunctions renders a template with custom function map
func (*TemplateService) RenderTemplateWithCustomFunctionsAndPartials ¶ added in v1.2.2
func (ts *TemplateService) RenderTemplateWithCustomFunctionsAndPartials( templateName string, partialNames []string, data any, funcMap template.FuncMap, ) (string, error)
RenderTemplateWithCustomFunctionsAndPartials renders a primary template together with named partial template files.