render

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFieldMapper added in v0.0.3

func NewFieldMapper(tag string) *fieldMapper

NewFieldMapper creates a new fieldMapper instance with the specified tag The tag determines how Go struct fields are exposed to JavaScript === NewFieldMapper 創建一個新的 fieldMapper 實例 tag 參數決定 Go 結構體字段如何暴露給 JavaScript

Types

type Entry

type Entry struct {
	Comp  string         // Component name / 組件名稱
	Props map[string]any // Component props / 組件屬性
}

Entry represents a component to be rendered, along with its props. === Entry 表示要渲染的組件及其屬性。

type RenderData

type RenderData struct {
	Entries *[]Entry          // Components to render / 要渲染的組件
	ErrPage string            // Error page component / 錯誤頁面組件
	SCData  SvelteContextData // Svelte context data / Svelte 上下文數據
}

RenderData contains all necessary data for rendering components === RenderData 包含渲染組件所需的所有數據

type Renderer

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

Renderer is a renderer for svelte components. It is safe to use concurrently across threads. === Renderer 是用於渲染 Svelte 組件的渲染器。它可以安全地在多個線程中並發使用。

func New

func New(serverFS *fs.FS, clientFS *fs.FS) *Renderer

New constructs a renderer from the given FS. The FS should be the "server" subdirectory of the build output from "npx golte". The second argument is the path where the JS, CSS, and other assets are expected to be served. === New 從給定的文件系統構建一個渲染器。 文件系統應該是 "npx golte" 構建輸出的 "server" 子目錄。 第二個參數是預期提供 JS、CSS 和其他資源的路徑。

func (*Renderer) Assets

func (r *Renderer) Assets() string

Assets returns the "assets" field that was used in the golte configuration file. === Assets 返回在 golte 配置文件中使用的 "assets" 字段。

func (*Renderer) Render

func (r *Renderer) Render(w http.ResponseWriter, data *RenderData) error

Render renders a slice of entries into the writer. It handles resource path extraction and replacement, and sets appropriate headers. === Render 將一系列條目渲染到寫入器中。 它處理資源路徑的提取和替換,並設置適當的標頭。

type ResourceEntry added in v0.0.3

type ResourceEntry struct {
	Path     string       // Resource path / 資源路徑
	Resource ResourceInfo // Resource tag info / 資源標籤信息
}

ResourceEntry represents a resource and its HTML tag information === ResourceEntry 表示資源及其 HTML 標籤信息

type ResourceInfo added in v0.0.3

type ResourceInfo struct {
	TagName    string            // HTML tag name / HTML 標籤名
	FullTag    string            // Complete tag string / 完整標籤字符串
	Attributes map[string]string // Tag attributes / 標籤屬性
}

ResourceInfo contains information about a resource tag === ResourceInfo 包含資源標籤的信息

type StyleEntry added in v0.0.3

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

StyleEntry represents a style tag and its replacement === StyleEntry 表示樣式標籤及其替換內容

type SvelteContextData

type SvelteContextData struct {
	URL string // Current URL / 當前 URL
}

SvelteContextData contains context data for Svelte components === SvelteContextData 包含 Svelte 組件的上下文數據

Jump to

Keyboard shortcuts

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