예제 #1
0
func initFuncMap() {
	beego.AddFuncMap("facility_color", models.GetFacilityColor)
	beego.AddFuncMap("severity_color", models.GetSeverityColor)
	beego.AddFuncMap("getid", models.GetId)
	beego.AddFuncMap("msgFormat", base.FormatMsg)
	beego.AddFuncMap("isIpAddress", base.IsIpAddress)
}
예제 #2
0
// create a new captcha.Captcha and auto AddFilter for serve captacha image
// and add a tempalte func for output html
func NewWithFilter(urlPrefix string, store cache.Cache) *Captcha {
	cpt := NewCaptcha(urlPrefix, store)

	// create filter for serve captcha image
	beego.InsertFilter(cpt.URLPrefix+"*", beego.BeforeRouter, cpt.Handler)

	// add to template func map
	beego.AddFuncMap("create_captcha", cpt.CreateCaptchaHtml)

	return cpt
}