view

package
v0.0.0-20260608 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

type Compiler struct {
	CachePath string
}

Compiler handles transpiling Goblade templates into standard Go html/template files.

func NewCompiler

func NewCompiler(cachePath string) *Compiler

NewCompiler creates a new Goblade compiler.

func (*Compiler) CompileFile

func (c *Compiler) CompileFile(path string) (string, error)

CompileFile reads a file, compiles it, and caches the output, returning the path to the cached file.

func (*Compiler) CompileString

func (c *Compiler) CompileString(raw string) string

Compile takes a raw Goblade string and returns the compiled html/template string. For Phase 3, we implement a lightweight parser/replacer as requested.

type Composer

type Composer func(data map[string]any)

Composer represents a callback that is executed before a view is rendered.

type ComposerRegistry

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

ComposerRegistry stores view composers for specific views.

func NewComposerRegistry

func NewComposerRegistry() *ComposerRegistry

NewComposerRegistry creates a new composer registry.

func (*ComposerRegistry) Compose

func (r *ComposerRegistry) Compose(view string, data map[string]any)

Compose executes all registered composers for a given view, modifying the data map in-place.

func (*ComposerRegistry) Register

func (r *ComposerRegistry) Register(view string, composer Composer)

Register adds a composer for a specific view or wildcard (*).

type Engine

type Engine struct {
	ViewPaths []string
	Compiler  *Compiler
	// contains filtered or unexported fields
}

Engine is the Goblade view rendering engine.

func NewEngine

func NewEngine(viewPaths []string, cachePath string) *Engine

NewEngine creates a new view engine.

func (*Engine) ClearAllStacks

func (e *Engine) ClearAllStacks()

ClearAllStacks clears all stacks.

func (*Engine) ClearStack

func (e *Engine) ClearStack(name string)

ClearStack clears a named stack.

func (*Engine) Each

func (e *Engine) Each(collection []any, templateName string, data map[string]any) (string, error)

Each iterates over a collection and renders a template for each item.

func (*Engine) GetShared

func (e *Engine) GetShared() map[string]any

GetShared returns all shared data.

func (*Engine) Make

func (e *Engine) Make(name string, data map[string]any) (string, error)

Make compiles and renders a view by name (e.g., "auth.login")

func (*Engine) Push

func (e *Engine) Push(name string, content string)

Push adds content to a named stack.

func (*Engine) Share

func (e *Engine) Share(key string, value any)

Share shares a piece of data across all views.

func (*Engine) ShareMany

func (e *Engine) ShareMany(data map[string]any)

ShareMany shares multiple pieces of data across all views.

func (*Engine) Stack

func (e *Engine) Stack(name string) []string

Stack returns all content in a named stack.

type Loop

type Loop struct {
	Index     int // 0-based
	Iteration int // 1-based
	Remaining int
	First     bool
	Last      bool
	Even      bool
	Odd       bool
	Depth     int
	Parent    *Loop // for nested loops (future)
}

Loop provides all standard Blade $loop variables inside @foreach.

Jump to

Keyboard shortcuts

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