templates

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateProject

func GenerateProject(templateName, projectPath, projectName, router string) error

GenerateProject creates a new project from templates using the new unified system

func ListTemplates

func ListTemplates() ([]string, error)

ListTemplates returns all available template files (legacy function for compatibility)

Types

type BackendConfig

type BackendConfig struct {
	SupportedRouters []string `yaml:"supported_routers"`
	Features         []string `yaml:"features"`
}

BackendConfig defines the backend configuration for a template

type FrontendOptions

type FrontendOptions struct {
	EnableScriptFrontends bool                   `yaml:"enable_script_frontends"`
	Options               []FrontendTemplateInfo `yaml:"options"`
}

FrontendOptions defines the frontend configuration options

type FrontendTemplateInfo

type FrontendTemplateInfo struct {
	Name        string                 `yaml:"name"`
	Description string                 `yaml:"description"`
	Framework   string                 `yaml:"framework"`
	DevCmd      string                 `yaml:"dev_cmd"`
	BuildCmd    string                 `yaml:"build_cmd"`
	TypesDir    string                 `yaml:"types_dir"`
	LibDir      string                 `yaml:"lib_dir"`
	StaticGen   config.StaticGenConfig `yaml:"static_gen"`
}

FrontendTemplateInfo contains metadata about a frontend template option

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles unified template operations

func GetTemplateManager

func GetTemplateManager() (*Manager, error)

GetTemplateManager creates and loads a template manager

func NewManager

func NewManager() *Manager

NewManager creates a new template manager

func (*Manager) GenerateFrontend

func (m *Manager) GenerateFrontend(templateName, frontendName, frontendPath string, data TemplateData) error

GenerateFrontend creates a frontend from template's frontend options

func (*Manager) GenerateProject

func (m *Manager) GenerateProject(templateName, projectPath, projectName, router string, customVars map[string]interface{}) error

GenerateProject creates a new project from a template

func (*Manager) GetTemplate

func (m *Manager) GetTemplate(name string) (*TemplateManifest, bool)

GetTemplate returns a template by name

func (*Manager) GetTemplateNames

func (m *Manager) GetTemplateNames() map[string]string

GetTemplateNames returns all available template names with descriptions

func (*Manager) ListTemplates

func (m *Manager) ListTemplates() []string

ListTemplates returns all available template names

func (*Manager) LoadTemplates

func (m *Manager) LoadTemplates() error

LoadTemplates loads all available templates from embedded filesystem

type TemplateData

type TemplateData struct {
	ProjectName        string
	ModuleName         string
	GoVersion          string
	Port               string
	Router             string
	SPARouting         bool
	ProjectDescription string
	CustomVars         map[string]interface{}
}

TemplateData contains the data passed to templates

type TemplateManifest

type TemplateManifest struct {
	Name        string          `yaml:"name"`
	Description string          `yaml:"description"`
	URL         string          `yaml:"url,omitempty"`
	Version     string          `yaml:"version"`
	Backend     BackendConfig   `yaml:"backend"`
	Frontend    FrontendOptions `yaml:"frontend"`
	Variables   []TemplateVar   `yaml:"template_variables,omitempty"`
}

TemplateManifest represents the main template.yaml configuration

func LoadTemplateFromData

func LoadTemplateFromData(data []byte) (*TemplateManifest, error)

LoadTemplateFromData loads a template from raw data

type TemplateOption

type TemplateOption struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
}

TemplateOption represents an option for select-type template variables

type TemplateVar

type TemplateVar struct {
	Name        string           `yaml:"name"`
	Type        string           `yaml:"type"`
	Description string           `yaml:"description"`
	Default     interface{}      `yaml:"default,omitempty"`
	Options     []TemplateOption `yaml:"options,omitempty"`
}

TemplateVar represents a template variable definition

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL