templateengine

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EngineGoTemplate = "go-template"
	EngineSimple     = "simple"
)
View Source
const SchemaVersionV2 = "pinax.template.v2"

Variables

This section is empty.

Functions

func ErrorCode

func ErrorCode(err error) string

func ReplaceManagedBlock

func ReplaceManagedBlock(body, name, replacement string) (string, error)

Types

type Context

type Context struct {
	Title    string
	Date     string
	DateTime string
	Project  string
	Tags     []string
	Vars     map[string]string
	Defaults map[string]string
	Queries  map[string]QueryResult
}

type Engine

type Engine struct{}

func New

func New() *Engine

func (*Engine) Render

func (e *Engine) Render(doc TemplateDocument, ctx Context) (RenderResult, error)

type Error

type Error struct {
	Code    string
	Message string
	Err     error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Example

type Example struct {
	Title   string            `yaml:"title" json:"title,omitempty"`
	Project string            `yaml:"project" json:"project,omitempty"`
	Tags    []string          `yaml:"tags" json:"tags,omitempty"`
	Vars    map[string]string `yaml:"vars" json:"vars,omitempty"`
}

type Issue

type Issue struct {
	Code    string
	Message string
}

type ManagedBlock

type ManagedBlock struct {
	Name         string `json:"name"`
	Start        int    `json:"start"`
	End          int    `json:"end"`
	ContentStart int    `json:"-"`
	ContentEnd   int    `json:"-"`
}

func InspectManagedBlocks

func InspectManagedBlocks(body string) ([]ManagedBlock, error)

type Metadata

type Metadata struct {
	SchemaVersion      string                              `yaml:"schema_version" json:"schema_version"`
	Name               string                              `yaml:"name" json:"name,omitempty"`
	Title              string                              `yaml:"title" json:"title,omitempty"`
	TemplateKind       string                              `yaml:"template_kind" json:"template_kind,omitempty"`
	ScenarioID         string                              `yaml:"scenario_id" json:"scenario_id,omitempty"`
	Intents            []string                            `yaml:"intents" json:"intents,omitempty"`
	UseCases           []string                            `yaml:"use_cases" json:"use_cases,omitempty"`
	Aliases            []string                            `yaml:"aliases" json:"aliases,omitempty"`
	Difficulty         string                              `yaml:"difficulty" json:"difficulty,omitempty"`
	Starter            *bool                               `yaml:"starter" json:"starter,omitempty"`
	Engine             string                              `yaml:"engine" json:"engine,omitempty"`
	Kind               string                              `yaml:"kind" json:"kind,omitempty"`
	Output             TemplateOutputMetadata              `yaml:"output" json:"output,omitempty"`
	OutputPolicy       TemplateOutputPolicy                `yaml:"output_policy" json:"output_policy,omitempty"`
	Variables          map[string]VariableMetadata         `yaml:"variables" json:"variables,omitempty"`
	VariableSchema     map[string]VariableMetadata         `yaml:"variable_schema" json:"variable_schema,omitempty"`
	Defaults           map[string]string                   `yaml:"defaults" json:"defaults,omitempty"`
	Example            Example                             `yaml:"example" json:"example,omitempty"`
	Queries            map[string]TemplateQueryDeclaration `yaml:"queries" json:"queries,omitempty"`
	AfterCreateActions []TemplateActionMetadata            `yaml:"after_create_actions" json:"after_create_actions,omitempty"`
	Maturity           string                              `yaml:"maturity" json:"maturity,omitempty"`
	ProofGate          TemplateProofGate                   `yaml:"proof_gate" json:"proof_gate,omitempty"`
	Pack               TemplatePackMetadata                `yaml:"pack" json:"pack,omitempty"`
	Lifecycle          string                              `yaml:"lifecycle" json:"lifecycle,omitempty"`
	Replacement        string                              `yaml:"replacement" json:"replacement,omitempty"`
	Metrics            map[string]string                   `yaml:"metrics" json:"metrics,omitempty"`
}

type QueryResult

type QueryResult struct {
	Columns []string
	Rows    []map[string]string
}

type RenderResult

type RenderResult struct {
	Body   string
	Issues []Issue
}

type TemplateActionMetadata added in v0.1.3

type TemplateActionMetadata struct {
	Name    string `yaml:"name" json:"name,omitempty"`
	Command string `yaml:"command" json:"command,omitempty"`
}

type TemplateDocument

type TemplateDocument struct {
	Name     string
	Engine   string
	Body     string
	Metadata Metadata
	Issues   []Issue
}

func ParseDocument

func ParseDocument(name, content string) (TemplateDocument, error)

type TemplateOutputMetadata

type TemplateOutputMetadata struct {
	PathPattern string `yaml:"path_pattern" json:"path_pattern,omitempty"`
}

type TemplateOutputPolicy added in v0.1.3

type TemplateOutputPolicy struct {
	PathPattern      string `yaml:"path_pattern" json:"path_pattern,omitempty"`
	AllowOverride    bool   `yaml:"allow_override" json:"allow_override,omitempty"`
	WriteBoundary    string `yaml:"write_boundary" json:"write_boundary,omitempty"`
	LegacyCompatible bool   `yaml:"legacy_compatible" json:"legacy_compatible,omitempty"`
}

type TemplatePackMetadata added in v0.1.3

type TemplatePackMetadata struct {
	ID        string `yaml:"id" json:"id,omitempty"`
	Source    string `yaml:"source" json:"source,omitempty"`
	Version   string `yaml:"version" json:"version,omitempty"`
	Readiness string `yaml:"readiness" json:"readiness,omitempty"`
}

type TemplateProofGate added in v0.1.3

type TemplateProofGate struct {
	Status           string `yaml:"status" json:"status,omitempty"`
	ManualReview     bool   `yaml:"manual_review" json:"manual_review,omitempty"`
	SnapshotRequired bool   `yaml:"snapshot_required" json:"snapshot_required,omitempty"`
	ReceiptRequired  bool   `yaml:"receipt_required" json:"receipt_required,omitempty"`
	RestoreHint      string `yaml:"restore_hint" json:"restore_hint,omitempty"`
}

type TemplateQueryDeclaration

type TemplateQueryDeclaration struct {
	Language string `yaml:"language" json:"language,omitempty"`
	SQL      string `yaml:"sql" json:"sql,omitempty"`
	Kind     string `yaml:"kind" json:"kind,omitempty"`
	MaxRows  int    `yaml:"max_rows" json:"max_rows,omitempty"`
	Required bool   `yaml:"required" json:"required,omitempty"`
}

type VariableMetadata

type VariableMetadata struct {
	Required    bool   `yaml:"required" json:"required,omitempty"`
	Description string `yaml:"description" json:"description,omitempty"`
	Default     string `yaml:"default" json:"default,omitempty"`
}

Jump to

Keyboard shortcuts

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