templater

package
v1.0.77 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Tokens = []Token{
	&RichToken{
		BasicToken: BasicToken{
			Key: "{{SOURCE}}",
			Extractor: func(record *resource.Record) string {
				return string(record.InfoData.Source)
			},
		},
		Description: "The source platform of the card",
	},
	&RichToken{
		BasicToken: BasicToken{
			Key: "{{PLATFORM_ID}}",
			Extractor: func(record *resource.Record) string {
				return record.InfoData.PlatformID
			},
		},
		Description: "The unique platform identifier for the card",
	},
	&RichToken{
		BasicToken: BasicToken{
			Key: "{{CHARACTER_ID}}",
			Extractor: func(record *resource.Record) string {
				return record.CharacterID
			},
		},
		Description: "The unique character identifier",
	},
	&RichToken{
		BasicToken: BasicToken{
			Key: "{{NAME}}",
			Extractor: func(record *resource.Record) string {
				return record.Name
			},
		},
		Description: "The name of the character",
	},
	&RichToken{
		BasicToken: BasicToken{
			Key: "{{TITLE}}",
			Extractor: func(record *resource.Record) string {
				return record.Title
			},
		},
		Description: "The title of the card",
	},
	&RichToken{
		BasicToken: BasicToken{
			Key: "{{CREATE_TIME}}",
			Extractor: func(record *resource.Record) string {
				return strconv.Itoa(int(timestamp.ConvertToSeconds(record.CreateTime)))
			},
		},
		Description: "The creation timestamp in seconds",
	},
	&RichToken{
		BasicToken: BasicToken{
			Key: "{{CREATE_DATE}}",
			Extractor: func(record *resource.Record) string {
				return strconv.Itoa(int(timestamp.ConvertToSeconds(record.CreateTime)))
			},
		},
		Description: "The creation date in UTC format",
	},
	&RichToken{
		BasicToken: BasicToken{
			Key: "{{UPDATE_TIME}}",
			Extractor: func(record *resource.Record) string {
				return strconv.Itoa(int(timestamp.ConvertToSeconds(record.UpdateTime)))
			},
		},
		Description: "The last update timestamp in seconds",
	},
	&RichToken{
		BasicToken: BasicToken{
			Key: "{{UPDATE_DATE}}",
			Extractor: func(record *resource.Record) string {
				return strconv.Itoa(int(timestamp.ConvertToSeconds(record.UpdateTime)))
			},
		},
		Description: "The last update date in UTC format",
	},
	&RichToken{
		BasicToken: BasicToken{
			Key: "{{C_NICKNAME}}",
			Extractor: func(record *resource.Record) string {
				return record.Nickname
			},
		},
		Description: "The nickname of the card creator",
	},
	&RichToken{
		BasicToken: BasicToken{
			Key: "{{C_USERNAME}}",
			Extractor: func(record *resource.Record) string {
				return record.Username
			},
		},
		Description: "The username of the card creator",
	},
}

Tokens is the list of available template tokens for resource records

Functions

This section is empty.

Types

type BasicToken

type BasicToken = templater.BasicToken[*resource.Record]

BasicToken is a simple token with a key and extractor function

type CompiledTemplate

type CompiledTemplate = templater.CompiledTemplate[*resource.Record]

CompiledTemplate is a pre-compiled template for resource records

type RichToken

type RichToken = templater.RichToken[*resource.Record]

RichToken is a token with additional metadata like description

type Templater

type Templater = templater.Templater[*resource.Record]

Templater is a template engine for resource records

func New

func New() *Templater

New creates a new Templater with all available tokens

type Token

type Token = templater.Token[*resource.Record]

Token is a template token that extracts values from resource records

Jump to

Keyboard shortcuts

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