templating

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	A4Width  = 595.28
	A4Height = 841.89
)
View Source
const UnsupportedCSSPropertyCode = "CSS001"

Variables

This section is empty.

Functions

func ApplyCSSDeclaration

func ApplyCSSDeclaration(node *html.Node, decl *css.Declaration, inlineAttrs map[string]struct{})

func ApplyPreparedStylesheet

func ApplyPreparedStylesheet(root *html.Node, stylesheet *PreparedStylesheet) error

func AttrVal

func AttrVal(n *html.Node, key string) string

func CSSDeclarationToAttr

func CSSDeclarationToAttr(decl *css.Declaration) (string, string, bool)

func CaptureAttrNames

func CaptureAttrNames(root *html.Node) map[*html.Node]map[string]struct{}

func CollectText

func CollectText(n *html.Node) string

func ElemChildren

func ElemChildren(n *html.Node) []*html.Node

func ExecuteNamedFromSourcesWithFuncs

func ExecuteNamedFromSourcesWithFuncs(templateSources []string, templateName string, data any, funcs template.FuncMap) (string, error)

func ExecuteNamedFromSourcesWithOptions

func ExecuteNamedFromSourcesWithOptions(templateSources []string, templateName string, data any, funcs template.FuncMap, options ExecuteOptions) (string, error)

func ExecuteNamedWithFuncs

func ExecuteNamedWithFuncs(templateSource, templateName string, data any, funcs template.FuncMap) (string, error)

func FindFirst

func FindFirst(n *html.Node, tag string) *html.Node

func FindFirstByID

func FindFirstByID(n *html.Node, tag, id string) *html.Node

func NormaliseInlineTextNode

func NormaliseInlineTextNode(raw string) string

func ParseBorderShorthand

func ParseBorderShorthand(value string) (width float64, style, color string)

func ParseCSSPageSettings

func ParseCSSPageSettings(cssText string, defaults PageSettings, parseLength func(string) (float64, bool)) (PageSettings, PageSettings, error)

func ParseLengthValue

func ParseLengthValue(raw string) (float64, bool)

func ParsePreparedStyledFragment

func ParsePreparedStyledFragment(htmlStr string, stylesheet *PreparedStylesheet) (*html.Node, error)

func ParseRunningFooterName

func ParseRunningFooterName(cssText string) (string, bool)

ParseRunningFooterName returns the running footer name when both rules exist:

  • footer { position: running(name); }
  • @page { @bottom-center { content: element(name); } }

and both names match.

func ParseStyledFragment

func ParseStyledFragment(htmlStr, cssText string) (*html.Node, error)

func ResolveNamedPageSize

func ResolveNamedPageSize(name string) (float64, float64, bool)

ResolveNamedPageSize returns width and height in points for a known CSS named page size, case-insensitive.

func SetOrReplaceAttr

func SetOrReplaceAttr(node *html.Node, key, value string)

func SupportedCSSProperties

func SupportedCSSProperties() []string

Types

type CSSSupportDiagnostic

type CSSSupportDiagnostic struct {
	Code     string
	Property string
	Selector string
}

func AnalyzeCSSSupport

func AnalyzeCSSSupport(cssText string) ([]CSSSupportDiagnostic, error)

func (CSSSupportDiagnostic) Error

func (d CSSSupportDiagnostic) Error() string

type ExecuteOptions

type ExecuteOptions struct {
	Context        context.Context
	MaxOutputBytes int64
}

type OutputLimitError

type OutputLimitError struct {
	Limit int64
}

func (*OutputLimitError) Error

func (e *OutputLimitError) Error() string

func (*OutputLimitError) Is

func (e *OutputLimitError) Is(target error) bool

type PageMargins

type PageMargins struct {
	Top    float64
	Right  float64
	Bottom float64
	Left   float64
}

type PageSettings

type PageSettings struct {
	Width   float64
	Height  float64
	Margins PageMargins
}

type PreparedStylesheet

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

func PrepareStylesheet

func PrepareStylesheet(cssText string) (*PreparedStylesheet, error)

type PreparedTemplates

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

func PrepareTemplates

func PrepareTemplates(templateSources []string, funcs template.FuncMap) (*PreparedTemplates, error)

func (*PreparedTemplates) Execute

func (prepared *PreparedTemplates) Execute(templateName string, data any, funcs template.FuncMap, options ExecuteOptions) (string, error)

Jump to

Keyboard shortcuts

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