views

package
v0.0.0-...-1125e7b Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: MPL-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	AlertLevelError   string = "danger"
	AlertLevelWarning string = "warning"
	AlertLevelInfo    string = "info"
	AlertLevelSuccess string = "success"

	// AlertMessageGeneric is displayed when any random error
	// is encountered by our backend.
	AlertMessageGeneric string = "Something went wrong. Please try again, and contact us if the problem persists."
)
View Source
const (
	LayoutDir   string = "views/layouts/"
	TemplateDir string = "views/"
	TemplateExt string = ".gohtml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Level   string
	Message string
}

Alert is used to render Bootstrap alert messages in templates.

type Data

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

Data is the top level structure that views expect data to come in.

func (*Data) AlertError

func (d *Data) AlertError(message string)

func (*Data) SetAlert

func (d *Data) SetAlert(err error)

type PublicError

type PublicError interface {
	error
	Public() string
}

type View

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

func NewView

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

func (*View) Render

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

Render is used to render the view with the predefined layout.

func (*View) ServeHTTP

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

Jump to

Keyboard shortcuts

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