template

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandPartials

func ExpandPartials(htmlStr string, fsys fs.FS, baseDir string) (string, error)

ExpandPartials takes HTML and recursively replaces custom element tags with partial content from a single filesystem (sibling-file lookup). This is the simple entry point; internally delegates to ExpandPartialsLayered.

func ExpandPartialsLayered

func ExpandPartialsLayered(htmlStr string, layers []FSLayer, registry map[string]string) (string, error)

ExpandPartialsLayered takes HTML and recursively replaces custom element tags with partial content. For each tag it consults, in order:

  1. Each FSLayer at path.Join(layer.BaseDir, tag+".html")
  2. registry[tag] (registered via Engine.RegisterPartial / UsePartials)

If no source has the tag, an error is returned that lists every location searched to aid debugging.

func ExtractGAttrs

func ExtractGAttrs(attrs string) string

ExtractGAttrs pulls out g-* attributes (and g-class:* etc.) from an attribute string.

func IsLiteral

func IsLiteral(s string) bool

func TransferAttrsToRoot

func TransferAttrsToRoot(htmlStr string, attrs string) string

TransferAttrsToRoot inserts attributes into the first opening tag of the HTML.

func ValidateDirectives

func ValidateDirectives(htmlStr string, ci *island.Info) error

ValidateDirectives parses HTML for g-* directives and validates them against the component's struct fields and methods. Called at Register() time.

Types

type FSLayer

type FSLayer struct {
	FS      fs.FS
	BaseDir string
	// Label is shown in "not found" error messages to help identify which
	// layer was searched (e.g. "island \"solar\" FS", "shared").
	Label string
}

FSLayer is one filesystem search location for partial resolution. Layers are consulted in order; the first hit wins.

Jump to

Keyboard shortcuts

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