template

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Templates *template.Template

Templates contain the pre-processed templates

Functions

func MakeNavbar

func MakeNavbar(r *http.Request, newNavbar []*NavbarNode)

MakeNavbar sets the active attribute based on the request url

Types

type Common

type Common struct {
	Language  string
	Localizer *language.Localizer

	FooterScripts []Script
	HeadLinks     []HeadLink
	NavBar        []*NavbarNode
	PageTitle     string
	User          *models.User
}

Common contains the variables used in nearly every template

func (*Common) AddFooterScript

func (t *Common) AddFooterScript(s Script)

AddFooterScript adds a footer script to the template

func (t *Common) AddHeadLink(l HeadLink)

AddHeadLink adds a headder link to the template

func (*Common) SetLanguage

func (t *Common) SetLanguage(l string)

SetLanguage sets the template's default language

func (*Common) SetLocalizer

func (t *Common) SetLocalizer(l *language.Localizer)

SetLocalizer sets the localizer the template will use to generate text

func (*Common) SetNavbar

func (t *Common) SetNavbar(nodes []*NavbarNode)

SetNavbar sets the top level navbar used by the template

func (*Common) SetUser

func (t *Common) SetUser(user *models.User)

SetUser sets the currently logged-in user

type HeadLink struct {
	HRef        string
	Rel         string
	Integrity   string
	CrossOrigin string
	Sizes       string
	Type        string
}

HeadLink is the data for a header link

type HomeTemplate

type HomeTemplate struct {
	Common
}

HomeTemplate contains the variables for the "home" template.

type InitTemplate

type InitTemplate interface {
	AddHeadLink(l HeadLink)
	AddFooterScript(s Script)
	SetLanguage(l string)
	SetLocalizer(l *language.Localizer)
	SetNavbar(nodes []*NavbarNode)
	SetUser(user *models.User)
}

InitTemplate are the functions a template implementing Common will have

type LoginTemplate

type LoginTemplate struct {
	Common

	BotImage string

	FormError    string
	FormEmail    string
	FormPassword string
}

LoginTemplate contains the variables for the "login" template.

type NavbarNode struct {
	Text     string
	URL      string
	MatchStr *regexp.Regexp
	FAIcon   string

	Active   bool
	Disabled bool

	Children []NavbarNode
}

NavbarNode is an entry on a navbar, can be nested one level

type Script

type Script struct {
	Src         string
	Integrity   string
	CrossOrigin string
}

Script is a javascript script

Jump to

Keyboard shortcuts

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