Documentation ¶
Index ¶
- func GetContentTemplate(ctx context.Context, content contenttype.ContentTyper, viewmode string, ...) string
- func GetSitePath(r *http.Request) string
- func GetSiteRouters(r *mux.Router) (SiteRouters, SiteRouters)
- func GetSites() []string
- func HandleContent(w http.ResponseWriter, r *http.Request)
- func InitRequest(next http.Handler) http.Handler
- func Load()
- func LoadSite(ctx context.Context, siteConfig map[string]interface{}) error
- func MatchTemplate(ctx context.Context, viewSection string, matchData map[string]interface{}, ...) (string, []string)
- func Output(w io.Writer, variables map[string]interface{}, viewType string, ...) error
- func OutputContent(w io.Writer, content contenttype.ContentTyper, siteIdentifier string, ...) error
- func OutputContentByID(w io.Writer, id int, siteIdentifier string, sitePath string, ...) error
- func OutputString(variables map[string]interface{}, viewType string, requestInfo RequestInfo) (string, error)
- func RegisterFunctions(name string, implementation func() TemplateFunctions)
- func RouteContent(siteRouters SiteRouters, defaultRouters SiteRouters)
- func SetSiteSettings(identifier string, settings SiteSettings)
- func TemplateExist(path string) bool
- func TemplateFolder() string
- func WashTemplatePath(path string, folder string) string
- type NewFunctions
- type RequestInfo
- type SiteRouters
- type SiteSettings
- type TemplateFunctions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetContentTemplate ¶
func GetContentTemplate(ctx context.Context, content contenttype.ContentTyper, viewmode string, siteIdentifier string) string
Get content view template, with site setting's template folder todo: support page content(render content) in matchData, eg. "render_field/display_type": "news", "render_contentype": "frontpage" - used like 'section' isolation based on visit page.
func GetSiteRouters ¶
func GetSiteRouters(r *mux.Router) (SiteRouters, SiteRouters)
func HandleContent ¶
func HandleContent(w http.ResponseWriter, r *http.Request)
Handle content, given mux variables: site: <site>, path: <site path>, id: <content id>
func MatchTemplate ¶
func MatchTemplate(ctx context.Context, viewSection string, matchData map[string]interface{}, fileName ...string) (string, []string)
MatchTemplate returns overrided template based on override config(eg. template_override.yaml)
func Output ¶
func Output(w io.Writer, variables map[string]interface{}, viewType string, requestInfo RequestInfo) error
Output proceeds template and output the results If variables includes "content" it will proceed as content, otherwise it process path(eg. email, sms, etc) see sitekit/templates/main.html common variables: debug, error match_data for non-content template matching
func OutputContent ¶
func OutputContent(w io.Writer, content contenttype.ContentTyper, siteIdentifier string, sitePath string, ctx context.Context, templateVars map[string]interface{}) error
Output content using conent template
func OutputContentByID ¶
func OutputString ¶
func OutputString(variables map[string]interface{}, viewType string, requestInfo RequestInfo) (string, error)
OutputString output template result as string See Output
func RegisterFunctions ¶
func RegisterFunctions(name string, implementation func() TemplateFunctions)
Register a set of functions name: 'namespace' of functions
func RouteContent ¶
func RouteContent(siteRouters SiteRouters, defaultRouters SiteRouters)
Handle contents after initialization
func SetSiteSettings ¶
func SetSiteSettings(identifier string, settings SiteSettings)
func TemplateExist ¶
check if template exists under web/templates(default) folder
func TemplateFolder ¶
func TemplateFolder() string
TemplateFolder() returns folder of templates. eg. under "templates" or "web/templates"
func WashTemplatePath ¶
add site template folder to template path if path starts from ~/, use path after ~/
Types ¶
type NewFunctions ¶
type NewFunctions = func() TemplateFunctions
type SiteRouters ¶
type SiteSettings ¶
type SiteSettings struct { Site string RootContent contenttype.ContentTyper DefaultContent contenttype.ContentTyper Host string Path string }
a basic setting to run a site.
func GetSiteSettings ¶
func GetSiteSettings(identifier string) SiteSettings
type TemplateFunctions ¶
type TemplateFunctions interface { GetMap() map[string]interface{} SetInfo(ctx RequestInfo) }
TemplateFunctions represents a set of functions To register a new set of function, first implement this interface and then invoke RegisterFunctions in init()