github.com/kotovmak/go-admin@v1.1.1/template/types/display/link.go (about) 1 package display 2 3 import ( 4 "github.com/kotovmak/go-admin/template" 5 "github.com/kotovmak/go-admin/template/types" 6 ) 7 8 type Link struct { 9 types.BaseDisplayFnGenerator 10 } 11 12 func init() { 13 types.RegisterDisplayFnGenerator("link", new(Link)) 14 } 15 16 func (l *Link) Get(args ...interface{}) types.FieldFilterFn { 17 prefix := "" 18 openInNewTabs := false 19 if len(args) > 0 { 20 prefix = args[0].(string) 21 } 22 if len(args) > 1 { 23 if openInNewTabsArr, ok := args[1].([]bool); ok { 24 openInNewTabs = openInNewTabsArr[0] 25 } 26 } 27 return func(value types.FieldModel) interface{} { 28 if openInNewTabs { 29 return template.Default().Link().SetURL(prefix + value.Value).OpenInNewTab().GetContent() 30 } else { 31 return template.Default().Link().SetURL(prefix + value.Value).GetContent() 32 } 33 } 34 }