pluginutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pluginutil provides shared utilities for krate's built-in plugins (file walking, HTML template building, path helpers). Community plugins are written in JavaScript and do not use this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolvePath

func ResolvePath(outputDir, relPath string) string

ResolvePath creates any needed directories and returns the absolute path.

func WalkMD

func WalkMD(root string, fn func(absPath, relPath string) error) error

WalkMD walks a directory and calls fn for each .md and .mdx file found. dirPath is the absolute path, relPath is relative to the base.

Types

type File

type File struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

File is a single output file produced by a plugin.

type FileWriter

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

FileWriter is a helper for collecting multiple files.

func NewFileWriter

func NewFileWriter() *FileWriter

NewFileWriter creates a FileWriter.

func (*FileWriter) Files

func (fw *FileWriter) Files() []File

Files returns the accumulated files.

func (*FileWriter) WriteFile

func (fw *FileWriter) WriteFile(path, content string)

WriteFile adds a file. The path is relative to the output directory.

type HTMLTemplate

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

HTMLTemplate provides a simple, fast HTML template builder. Unlike text/template or html/template, it uses a builder pattern that avoids reflection for maximum speed.

func NewHTML

func NewHTML() *HTMLTemplate

NewHTML creates a new HTML template builder.

func (*HTMLTemplate) Esc

func (h *HTMLTemplate) Esc(s string)

Esc writes a string with HTML escaping to the template.

func (*HTMLTemplate) Reset

func (h *HTMLTemplate) Reset()

Reset clears the template builder for reuse.

func (*HTMLTemplate) String

func (h *HTMLTemplate) String() string

String returns the built template string.

func (*HTMLTemplate) W

func (h *HTMLTemplate) W(s string)

W writes a string to the template.

func (*HTMLTemplate) Wf

func (h *HTMLTemplate) Wf(format string, args ...interface{})

Wf writes a formatted string to the template.

Jump to

Keyboard shortcuts

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