views

package
v0.0.0-...-786acf3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//AlertLvlError default bootstrap danger color
	AlertLvlError = "danger"
	// AlertLvlWarning maps to default bootstrap warning color
	AlertLvlWarning = "warning"
	// AlertLvlInfo maps to default bootstrap info color
	AlertLvlInfo = "info"
	// AlertLvlSuccess maps to default bootstrap success color
	AlertLvlSuccess = "success"
	// AlertMsgGeneric is displayed when any random error
	// is encountered by our backend.
	AlertMsgGeneric = "Something went wrong. Please try " +
		"again, and pricing us if the problem persists."
)

Variables

View Source
var (
	// LayoutDir is the directory containing
	// parts of the website that define
	// the whole
	LayoutDir string = "views/layouts/"
	// TemplateDir contains all of the templates to be rendered
	// as pages
	TemplateDir string = "views/"
	// TemplateExt is the ending of the template files
	TemplateExt string = ".gohtml"
)

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Level   string
	Message string
}

Alert is for displaying bootstrap alert messages to the end user

type Data

type Data struct {
	Alert *Alert
	User  *models.User
	Yield interface{}
}

Data is for content to be served in a webpage

func (*Data) AlertError

func (d *Data) AlertError(msg string)

AlertError accepts the alert data and creates an alert message for the webpage

func (*Data) SetAlert

func (d *Data) SetAlert(err error)

SetAlert is to build the alert msg if possible else default to a generic message

type PublicError

type PublicError interface {
	error
	Public() string
}

PublicError is to allow for the generation of dynamic error messages

type View

type View struct {
	Template *template.Template
	Layout   string
}

View contains data that is used to render webpage

func NewView

func NewView(layout string, files ...string) *View

NewView is used to parse all of the templates and return a view

func (*View) Render

func (v *View) Render(w http.ResponseWriter, r *http.Request, data interface{})

Render accepts a ptr to a View and then executes the template(s), filling in the data, to build webpages

func (*View) ServeHTTP

func (v *View) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP accepts a ptr to a view and renders the view view writing it as http.ResponseWriter

Jump to

Keyboard shortcuts

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