gmvc

package
v1.13.3-0...-1915ff6 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package gmvc provides basic object classes for MVC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	Request  *ghttp.Request
	Response *ghttp.Response
	Server   *ghttp.Server
	Cookie   *ghttp.Cookie
	Session  *ghttp.Session
	View     *View
}

Controller is used for controller register of ghttp.Server.

func (*Controller) Exit

func (c *Controller) Exit()

Exit equals to function Request.Exit().

func (*Controller) Init

func (c *Controller) Init(r *ghttp.Request)

Init is the callback function for each request initialization.

func (*Controller) Shut

func (c *Controller) Shut()

Shut is the callback function for each request close.

type M

type M = Model // M is alias for Model, just for short write purpose.

type Model

type Model = *gdb.Model // Model is alias for *gdb.Model.

type View

type View struct {
	// contains filtered or unexported fields
}

View is the view object for controller. It's initialized when controller request initializes and destroyed when the controller request closes.

func NewView

func NewView(w *ghttp.Response) *View

NewView creates and returns a controller view object.

func (*View) Assign

func (view *View) Assign(key string, value interface{})

Assign assigns one template variable to this view object.

func (*View) Assigns

func (view *View) Assigns(data gview.Params)

Assigns assigns template variables to this view object.

func (*View) BindFunc

func (view *View) BindFunc(name string, function interface{})

BindFunc registers customized template function named <name> with given function <function> to current view object. The <name> is the function name which can be called in template content.

func (*View) BindFuncMap

func (view *View) BindFuncMap(funcMap gview.FuncMap)

BindFuncMap registers customized template functions by map to current view object. The key of map is the template function name and the value of map is the address of customized function.

func (*View) Display

func (view *View) Display(file ...string) error

Display parses and writes the parsed template file content to http response.

func (*View) DisplayContent

func (view *View) DisplayContent(content string) error

DisplayContent parses and writes the parsed content to http response.

func (*View) LockFunc

func (view *View) LockFunc(f func(data gview.Params))

LockFunc locks writing for template variables by callback function <f>.

func (*View) Parse

func (view *View) Parse(file string) (string, error)

Parse parses given template file <tpl> with assigned template variables and returns the parsed template content.

func (*View) ParseContent

func (view *View) ParseContent(content string) (string, error)

ParseContent parses given template file <file> with assigned template variables and returns the parsed template content.

func (*View) RLockFunc

func (view *View) RLockFunc(f func(data gview.Params))

LockFunc locks reading for template variables by callback function <f>.

Jump to

Keyboard shortcuts

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