badgetemplate

package
Version: v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package badgetemplate contains an abstraction of how to represent non-compiled badge templates in an application For built-in badge templates, refer to the templates package instead.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidThemeName = errors.New("invalid theme name")
View Source
var ErrThemeNotFound = errors.New("theme not found")
View Source
var ThemeNameRegex = regexp.MustCompile(`^[a-zA-Z0-9\-_]+$`)

Functions

This section is empty.

Types

type BadgeTemplate

type BadgeTemplate interface {
	// ListThemes returns the names of all themes that are available with this template
	ListThemes() ([]string, error)

	// TemplateBody is the source code of this template's template.tmpl
	TemplateBody() (string, error)

	// ThemeJSON returns the raw JSON of the theme with the specified name (or ErrThemeNotFound, if no such theme exists)
	ThemeJSON(themeName string) ([]byte, error)

	// ParametersJSON returns the raw JSON of this template's parameters.json
	ParametersJSON() ([]byte, error)
}

BadgeTemplate abstractly represents the components of a non-compiled badge template

type FilesystemTemplate

type FilesystemTemplate struct {
	BasePath string
}

A FilesystemTemplate represents a template that is located on disk at the specified BasePath.

func (*FilesystemTemplate) ListThemes

func (t *FilesystemTemplate) ListThemes() ([]string, error)

func (*FilesystemTemplate) ParametersJSON

func (t *FilesystemTemplate) ParametersJSON() ([]byte, error)

func (*FilesystemTemplate) TemplateBody

func (t *FilesystemTemplate) TemplateBody() (string, error)

func (*FilesystemTemplate) ThemeJSON

func (t *FilesystemTemplate) ThemeJSON(themeName string) ([]byte, error)

type InMemoryTemplate

type InMemoryTemplate struct {
	Body      string
	ParamSpec []byte
	Themes    map[string][]byte
}

An InMemoryTemplate holds all template data in memory instead of loading from disk.

func (*InMemoryTemplate) ListThemes

func (t *InMemoryTemplate) ListThemes() ([]string, error)

func (*InMemoryTemplate) ParametersJSON

func (t *InMemoryTemplate) ParametersJSON() ([]byte, error)

func (*InMemoryTemplate) TemplateBody

func (t *InMemoryTemplate) TemplateBody() (string, error)

func (*InMemoryTemplate) ThemeJSON

func (t *InMemoryTemplate) ThemeJSON(themeName string) ([]byte, error)

Jump to

Keyboard shortcuts

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