Documentation ¶
Index ¶
- func ExtractCurrency(tplData pongo2.Context) string
- func ExtractTimezone(tplData pongo2.Context) string
- func PrepareFilters(locale string, timezone string, currencyCode string) map[string]pongo2.FilterFunction
- type AssetInfo
- type FilterPreparation
- type TemplateContext
- type TemplateInfoSource
- type TemplateInfoSourceDetail
- type TemplatePathFactory
- type Templating
- func (t *Templating) ExtractTemplateInfoFromRequest(request TemplateInfoSource) (templateName string, hob string, locale string, format string)
- func (t *Templating) FindAndRenderTemplate(source TemplateInfoSource, templateData pongo2.Context) (string, error)
- func (t *Templating) FindTemplatePath(source TemplateInfoSource) (string, error)
- func (t *Templating) RenderTemplate(templatePath string, templateData pongo2.Context) (string, error)
- func (t *Templating) RenderTemplateFromSource(request TemplateInfoSource, targets ...string) (map[string]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractCurrency ¶
ExtractCurrency extracts the currency isocode from various locations in the supplied Context, and defaults to 'GBP'.
func ExtractTimezone ¶
ExtractTimezone extracts the time-zone isocode from various location in the supplied Context, and defaults to 'Europe/London'.
func PrepareFilters ¶
func PrepareFilters(locale string, timezone string, currencyCode string) map[string]pongo2.FilterFunction
PrepareFilters a FilterPreparation function - prepares filters before rendering the template
Types ¶
type FilterPreparation ¶
type FilterPreparation func(locale string, timezone string, currencyCode string) map[string]pongo2.FilterFunction
FilterPreparation defines the signature of functions used to prepare the filters
type TemplateContext ¶
type TemplateContext interface { }
TemplateContext an interface to serve as a generic type passed to the TemplatePathFactory - extend later?
type TemplateInfoSource ¶
type TemplateInfoSource interface { SetFormat(string) GetFormat(string) string GetTemplate() TemplateInfoSourceDetail GetTemplateData() map[string]interface{} PathOptions() ([]string, error) }
TemplateInfoSource is a source of data to be used in rendering using a template
type TemplateInfoSourceDetail ¶
type TemplateInfoSourceDetail interface { GetId() string GetRegulatoryArea() string GetLocale() string }
TemplateInfoSourceDetail contains details for use with rendering
type TemplatePathFactory ¶
type TemplatePathFactory func(ctx TemplateContext) ([]string, error)
TemplatePathFactory defines the signature of a function to get the paths to the templates
type Templating ¶
type Templating struct { TemplateSet *pongo2.TemplateSet FilterPreparation FilterPreparation // contains filtered or unexported fields }
Templating wraps up a set of templates (TemplateSet) with a function to find the template files, and function to prepare the filters
func NewTemplating ¶
func NewTemplating(fetcher pongo2.TemplateFetcher, af AssetInfo) *Templating
NewTemplating creates a Templating instance - sets templatesDir and initializes template cache
func (*Templating) ExtractTemplateInfoFromRequest ¶
func (t *Templating) ExtractTemplateInfoFromRequest(request TemplateInfoSource) (templateName string, hob string, locale string, format string)
ExtractTemplateInfoFromRequest extracts template info from the supplied TemplateInfoSource, the info being: templateName, hob, locale and format
func (*Templating) FindAndRenderTemplate ¶
func (t *Templating) FindAndRenderTemplate(source TemplateInfoSource, templateData pongo2.Context) (string, error)
FindAndRenderTemplate finds and renders a given TemplateSet and templatePath with the upplied data and context.
func (*Templating) FindTemplatePath ¶
func (t *Templating) FindTemplatePath(source TemplateInfoSource) (string, error)
FindTemplatePath Returns a template path based on the path-options that are given to it
func (*Templating) RenderTemplate ¶
func (t *Templating) RenderTemplate(templatePath string, templateData pongo2.Context) (string, error)
RenderTemplate renders a given templatePath with its data retruining the rendered template as a string
func (*Templating) RenderTemplateFromSource ¶
func (t *Templating) RenderTemplateFromSource(request TemplateInfoSource, targets ...string) (map[string]string, error)
RenderTemplateFromSource renders the supplied TemplateInfoSource using the 'self' templatData and context to a list of 'targets' output types (say, 'html', 'tsv' etc.).