converttext

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package converttext is a stateless text-conversion tool. Wick mounts it under /tools/{meta.Key} once per app.RegisterTool call — the same Register function can back multiple cards, each with its own meta and seeded Config.

Runtime-editable knobs live in Config (see config.go); live values are read via c.Cfg("init_text") / c.Cfg("init_type").

templ: version: v0.3.1020

Index

Constants

This section is empty.

Variables

View Source
var StaticFS embed.FS

Functions

func Convert

func Convert(text string, ct ConvertType) string

Convert transforms text according to ct. Unknown types return text unchanged.

func IndexBody added in v0.9.0

func IndexBody(basePath, inputText string, convertType ConvertType, result string) templ.Component

func Register

func Register(r tool.Router)

Register wires the convert-text routes on the scoped Router. All paths are relative to the instance's /tools/{meta.Key} base.

Types

type Config

type Config struct {
	// InitText is the seed value dropped into the input textarea on
	// first load. Empty = blank textarea.
	InitText string `wick:"desc=Seed text dropped into the input textarea on first load."`

	// InitType is the conversion type pre-selected on first load.
	// Dropdown options are pinned at module boot.
	InitType string `wick:"desc=Seed conversion type pre-selected on first load.;dropdown=uppercase|lowercase|titlecase|sentencecase|alternating"`
}

Config is the typed, runtime-editable configuration for a convert-text instance. Each exported field with a `wick:"..."` tag becomes one row in the `configs` table, scoped to this instance's Meta.Key. Admin UI widgets are picked from the Go type + tag flags.

See entity.StructToConfigs for the full tag grammar; here is a short reference:

desc=...          → field description (shown in admin UI)
required          → block tool via c.Missing() until set
secret            → mask value in UI, redact in responses
locked            → operator-only (UI renders read-only)
regen             → "Regenerate" button in UI (pairs w/ generator)
textarea          → multi-line input
dropdown=a|b|c    → select with the given pipe-separated options
number            → numeric input (auto from int/float)
checkbox          → bool toggle (auto from bool)
email | url | color | date | datetime → typed input widgets
key=custom_name   → override default snake_case key

type ConvertType

type ConvertType string

ConvertType defines available text transformations.

const (
	ConvertUppercase      ConvertType = "uppercase"
	ConvertLowercase      ConvertType = "lowercase"
	ConvertTitleCase      ConvertType = "titlecase"
	ConvertSentence       ConvertType = "sentence"
	ConvertAlternating    ConvertType = "alternating"
	ConvertLinesToEscaped ConvertType = "lines-to-escaped"
	ConvertEscapedToLines ConvertType = "escaped-to-lines"
)

Jump to

Keyboard shortcuts

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