Documentation ¶
Index ¶
- Constants
- Variables
- func MRender(in string) template.HTML
- func SafeHTML(input string) template.HTML
- type Asset
- type Merge
- type Message
- type Page
- func (p Page) GetDescription(def string) string
- func (p Page) GetFbAppId(def string) string
- func (p Page) GetOgDescription(def string) string
- func (p Page) GetOgImage(def string) string
- func (p Page) GetOgLocale() string
- func (p Page) GetOgTitle(def string) string
- func (p Page) GetOgType() string
- func (p Page) GetOgUrl() string
- func (p Page) GetTitle(def string) string
- func (p Page) GetTwitterCard(def string) string
- func (p Page) GetTwitterCreator(def string) string
- func (p Page) GetTwitterDescription(def string) string
- func (p Page) GetTwitterImage(def string) string
- func (p Page) GetTwitterSite(def string) string
- func (p Page) GetTwitterTitle(def string) string
- type Partial
- type Vault
- func (v *Vault) AddJsonManifest(input string) error
- func (v *Vault) GetCssPath(key string) string
- func (v *Vault) GetImgPath(key string) string
- func (v *Vault) GetJsPath(key string) string
- func (v *Vault) Partial(name string, payload interface{}) (template.HTML, error)
- func (v *Vault) Redirect(w http.ResponseWriter, r *http.Request, url string)
- func (v *Vault) RedirectCode(w http.ResponseWriter, r *http.Request, url string, code int)
- func (v *Vault) RegisterCSS(css Asset)
- func (v *Vault) RegisterImg(img Asset)
- func (v *Vault) RegisterJS(js Asset)
- func (v *Vault) RegisterMerge(merge Merge)
- func (v *Vault) RegisterMessage(message *Message)
- func (v *Vault) RegisterMessageFS(message fs.FS)
- func (v *Vault) RegisterPage(page *Page)
- func (v *Vault) RegisterPartial(partial *Partial)
- func (v *Vault) RegisterTemplateFunc(key string, fn interface{})
- func (v *Vault) RenderJson(w http.ResponseWriter, data interface{})
- func (v *Vault) RenderMessageHtml(w io.Writer, key string, data map[string]interface{}) error
- func (v *Vault) RenderMessagePlain(w io.Writer, key string, data map[string]interface{}) error
- func (v *Vault) RenderPage(w http.ResponseWriter, r *http.Request, key string, ...)
- func (v *Vault) SetErrorFlash(w http.ResponseWriter, r *http.Request, message string)
- func (v *Vault) SetSuccessFlash(w http.ResponseWriter, r *http.Request, message string)
Constants ¶
const ( Flash = "flash" FlashError = "flasherror" FlashSuccess = "flashsuccess" )
Variables ¶
var ErrorMessageNotFound = errors.New("error message not found")
var ErrorNoTemplate = errors.New("error no template")
var ErrorParsingMessage = errors.New("error parsing message")
var ErrorParsingPartial = errors.New("error parsing partial")
var ErrorPartialNotFound = errors.New("partial not found")
Functions ¶
Types ¶
type Page ¶
type Page struct { Key string `json:"key"` Tpls []string `json:"tpls"` Cached *template.Template Title string `json:"title"` Description string `json:"description"` Canonical string `json:"canonical"` OgURL string `json:"ogurl"` OgTitle string `json:"ogtitle"` OgDescription string `json:"ogdescription"` OgImage string `json:"ogimage"` OgImageType string `json:"ogimagetype"` OgImageWidth string `json:"ogimagewidth"` OgImageHeight string `json:"ogimageheight"` FbAppID string `json:"fbappid"` OgType string `json:"ogtype"` OgLocale string `json:"oglocale"` TwitterCard string `json:"twittercard"` TwitterSite string `json:"twittersite"` TwitterTitle string `json:"twittertitle"` TwitterDescription string `json:"twitterdescription"` TwitterCreator string `json:"twittercreator"` TwitterImage string `json:"twitterimage"` }
func (Page) GetDescription ¶
GetDescription returns page description, intended to be called from the template with a default value
func (Page) GetFbAppId ¶
GetFbAppId returns the fb app id or the default value passed in
func (Page) GetOgDescription ¶
GetOgDescription returns the open graph description, the regular description, or the default value passed in
func (Page) GetOgImage ¶
GetOgImage returns the open graph image or the default value passed in
func (Page) GetOgLocale ¶
GetOgLocale returns the open graph locale or the default locale
func (Page) GetOgTitle ¶
GetOgTitle returns the open graph title for the page, or the regular title, or the default value passed in
func (Page) GetTitle ¶
GetTitle returns the page title, intended to be called from the template with a default value
func (Page) GetTwitterCard ¶
GetTwitterCard returns the twitter card summary
func (Page) GetTwitterCreator ¶
GetTwitterCreator returns the twitter creator or default
func (Page) GetTwitterDescription ¶
GetTwitterDescription returns the twitter description or the page description or the default
func (Page) GetTwitterImage ¶
GetTwitterImage returns the twitter image or default
func (Page) GetTwitterSite ¶
GetTwitterSite returns the twitter site or default. i.e. @KendellFab
func (Page) GetTwitterTitle ¶
GetTwitterTitle returns the twitter title or the page title or the default
type Vault ¶ added in v0.4.0
Vault is a wrapper around the go template library. The pageFS parameter is to be the root file system used where all of the page & partial tpls reference from
func (*Vault) AddJsonManifest ¶ added in v0.4.0
AddJsonManifest is a json representation of the pages, partials, messages, and assets to be managed by this Vault instance It is to be formatted as
{ "pages": [], "partials": [], "messages": [], "js": [], "css": [], "img": [] }
It is recommended that this use the embed directive to get a string from the filesystem. However it could be stored as a string and passed in.
func (*Vault) GetCssPath ¶ added in v0.4.0
func (*Vault) GetImgPath ¶ added in v0.4.0
func (*Vault) Partial ¶ added in v0.4.0
Partial allows a partial to be loaded within the template. Use: {{ partial "key" . }}
func (*Vault) RedirectCode ¶ added in v0.4.0
RedirectCode returns a redirect with given http status
func (*Vault) RegisterCSS ¶ added in v0.4.0
func (*Vault) RegisterImg ¶ added in v0.4.0
func (*Vault) RegisterJS ¶ added in v0.4.0
func (*Vault) RegisterMerge ¶ added in v0.4.0
func (*Vault) RegisterMessage ¶ added in v0.4.0
func (*Vault) RegisterMessageFS ¶ added in v0.4.0
RegisterMessageFS takes a file system where the message tpls reference from
func (*Vault) RegisterPage ¶ added in v0.4.0
func (*Vault) RegisterPartial ¶ added in v0.4.0
func (*Vault) RegisterTemplateFunc ¶ added in v0.4.0
func (*Vault) RenderJson ¶ added in v0.4.0
func (v *Vault) RenderJson(w http.ResponseWriter, data interface{})
RenderJson is a shortcut method for rendering json to the response
func (*Vault) RenderMessageHtml ¶ added in v0.4.0
func (*Vault) RenderMessagePlain ¶ added in v0.4.0
func (*Vault) RenderPage ¶ added in v0.4.0
func (*Vault) SetErrorFlash ¶ added in v0.4.0
SetErrorFlash sets a flash error message if the fazer.store is not nil
func (*Vault) SetSuccessFlash ¶ added in v0.4.0
SetSuccessFlash sets a flash success message if the fazer.store is not nil