view

package
v0.0.0-...-ea22c33 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FlashError is a bootstrap class
	FlashError = "alert-danger"
	// FlashSuccess is a bootstrap class
	FlashSuccess = "alert-success"
	// FlashNotice is a bootstrap class
	FlashNotice = "alert-info"
	// FlashWarning is a bootstrap class
	FlashWarning = "alert-warning"
)

Functions

func Configure

func Configure(vi View)

Configure sets the view information

func FileTime

func FileTime(name string) (string, error)

FileTime returns the modification time of the file

func LoadPlugins

func LoadPlugins(fms ...template.FuncMap)

LoadPlugins will combine all template.FuncMaps into one map and then set the plugins for the templates If a func already exists, it is rewritten, there is no error

func LoadTemplates

func LoadTemplates(rootTemp string, childTemps []string)

LoadTemplates will set the root and child templates

func Repopulate

func Repopulate(list []string, src url.Values, dst map[string]interface{})

Repopulate updates the dst map so the form fields can be refilled

func Validate

func Validate(req *http.Request, required []string) (bool, string)

Validate returns true if all the required form values are passed

Types

type Flash

type Flash struct {
	Message string
	Class   string
}

Flash Message

type Template

type Template struct {
	Root     string   `json:"Root"`
	Children []string `json:"Children"`
}

Template root and children

type View

type View struct {
	BaseURI   string
	Extension string
	Folder    string
	Name      string
	Caching   bool
	Vars      map[string]interface{}
	// contains filtered or unexported fields
}

View attributes

func New

func New(req *http.Request) *View

New returns a new view

func ReadConfig

func ReadConfig() View

ReadConfig returns the configuration

func (*View) AssetTimePath

func (v *View) AssetTimePath(s string) (string, error)

AssetTimePath returns a URL with the proper base uri and timestamp appended. Works for CSS and JS assets Determines if local or on the web

func (*View) PrependBaseURI

func (v *View) PrependBaseURI(s string) string

PrependBaseURI prepends the base URI to the string

func (*View) Render

func (v *View) Render(w http.ResponseWriter)

Render renders a template to the writer

func (*View) RenderSingle

func (v *View) RenderSingle(w http.ResponseWriter)

RenderSingle renders a template to the writer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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