Version: v2.2.0 Latest Latest

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

Go to latest
Published: Jun 26, 2022 License: Apache-2.0 Imports: 12 Imported by: 0




This section is empty.


View Source
var BuiltinTemplates = map[string]badgetemplate.BadgeTemplate{
	"builtin-standard-badge": &standard_badge.Template,
	"builtin-example-circle": &example_circle.Template,

BuiltinTemplates is an index of all templates built into ./badges. They are ready to use with Renderer's CompileTemplate method.

View Source
var ErrFontNotFound = errors.New("the requested font was not found")
View Source
var ErrInvalidParams = errors.New("invalid parameters were provided to renderer")
View Source
var ErrTemplateExecutionFailed = errors.New("template execution failed")


This section is empty.


type CompiledTemplate

type CompiledTemplate struct {
	Template  *template.Template
	ParamSpec paramspec.Tree

CompiledTemplate contains a compiled badge template and corresponding parameter specification

type Renderer

type Renderer struct {
	// The loaded fonts
	Fonts map[string]*sfnt.Font

The Renderer holds the configuration necessary to render badges

func (*Renderer) BuildTemplateFuncMap

func (r *Renderer) BuildTemplateFuncMap() template.FuncMap

BuildTemplateFuncMap builds the functions that are to be injected into templates when they're being compiled.

func (*Renderer) CompileDefaultTemplate

func (r *Renderer) CompileDefaultTemplate() *CompiledTemplate

CompileDefaultTemplate is a convenience function that compiles the built-in standard badge template against this renderer.

func (*Renderer) CompileTemplate

func (r *Renderer) CompileTemplate(input badgetemplate.BadgeTemplate) (*CompiledTemplate, error)

CompileTemplate compiles a badge template for later use with this Renderer's Render method.

func (*Renderer) Render

func (r *Renderer) Render(template *CompiledTemplate, parameters map[string]interface{}) (string, error)

Render renders a badge template using the Renderer's current configuration and the given parameters The parameters will be converted and validated against the compiled template's parameter specification prior to rendering. Note that the result's leading and trailing spaces will be trimmed.

Jump to

Keyboard shortcuts

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