view

package module
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 13 Imported by: 3

README

view

view 是 infrago 的模块

包定位

  • 类型:模块
  • 作用:视图渲染模块,负责模板加载与渲染输出。

主要功能

  • 对上提供统一模块接口
  • 对下通过驱动接口接入具体后端
  • 支持按配置切换驱动实现

快速接入

import _ "github.com/infrago/view"
[view]
driver = "default"

驱动实现接口列表

以下接口由驱动实现(来自模块 driver.go):

Driver
  • Connect(*Instance) (Connection, error)
Connection
  • Open() error
  • Health() (Health, error)
  • Close() error
  • Parse(Body) (string, error)

全局配置项(所有配置键)

配置段:[view]

  • 未检测到配置键(请查看模块源码的 configure 逻辑)

说明

  • setting 一般用于向具体驱动透传专用参数
  • 多实例配置请参考模块源码中的 Config/configure 处理逻辑

Documentation

Index

Constants

View Source
const (
	NAME = "VIEW"
)

Variables

View Source
var (
	ErrInvalidConnection = errors.New("invalid view connection")
)

Functions

func Parse

func Parse(body Body) (string, error)

func SetFS added in v0.7.0

func SetFS(fsys fs.FS)

Types

type Body

type Body struct {
	View     string
	Site     string
	Language string
	Timezone *time.Location
	Data     Map
	Model    Map
	Helpers  Map
}

type Config

type Config struct {
	Driver  string
	Root    string
	Shared  string
	Left    string
	Right   string
	Setting Map
}

type Connection added in v0.7.0

type Connection interface {
	Open() error
	Health() (Health, error)
	Close() error

	Parse(Body) (string, error)
}

type Driver

type Driver interface {
	Connect(*Instance) (Connection, error)
}

type Health

type Health struct {
	Workload int64
}

type Helper

type Helper struct {
	Name   string   `json:"name"`
	Desc   string   `json:"desc"`
	Alias  []string `json:"alias"`
	Action Any      `json:"-"`
}

type Instance

type Instance struct {
	Config  Config
	Setting Map
	// contains filtered or unexported fields
}

type Module

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

func (*Module) Close added in v0.7.0

func (m *Module) Close()

func (*Module) Config

func (m *Module) Config(global Map)

func (*Module) Open added in v0.7.0

func (m *Module) Open()

func (*Module) Parse

func (m *Module) Parse(body Body) (string, error)

func (*Module) Register

func (m *Module) Register(name string, value Any)

func (*Module) RegisterConfig added in v0.7.0

func (m *Module) RegisterConfig(config Config)

func (*Module) RegisterDriver added in v0.7.0

func (m *Module) RegisterDriver(name string, driver Driver)

func (*Module) RegisterHelper added in v0.7.0

func (m *Module) RegisterHelper(name string, helper Helper)

func (*Module) Setup added in v0.7.0

func (m *Module) Setup()

func (*Module) Start added in v0.7.0

func (m *Module) Start()

func (*Module) Stop added in v0.7.0

func (m *Module) Stop()

Jump to

Keyboard shortcuts

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