xtemplate

package
v0.0.0-...-73d6a9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

xtemplate provides html/templates

this module is different from the others because, this one uses a static configuration into the module itself and does not load configs from env vars, I have made this decision because usually the location of templates is defined at compilation time and not at runtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module

func Module() fx.Option

Module provides a html/template fully configured.

Types

type Config

type Config struct {
	RootDir   string `yaml:"root"`
	Extension string `yaml:"extension"`
}

func LoadConfig

func LoadConfig(params LoadConfigParams) (Config, error)

type Func

type Func struct {
	Name string
	Func interface{}
}

type FuncMapMappings

type FuncMapMappings struct {
	fx.In

	Functions []*Func `group:"x_template_funcmap_mappings"`
}

FuncMapMappings gets populated by the container with all the FuncMapping regostered in the given group

type FuncMapping

type FuncMapping struct {
	fx.Out

	Func *Func `group:"x_template_funcmap_mappings"`
}

FuncMapping Necessary to register more than one Func

func NewFuncMapping

func NewFuncMapping(name string, fn interface{}) FuncMapping

type LoadConfigParams

type LoadConfigParams struct {
	fx.In

	Provider config.Provider `optional:"true"`
}

type Template

type Template struct {
	fx.In

	Template *template.Template `name:"x_template"`
}

Template is necessary to access the template by name

type TemplateQualifier

type TemplateQualifier struct {
	fx.Out

	Template *template.Template `name:"x_template"`
}

TemplateQualifier is necessary to give a name to the template

func NewTemplate

func NewTemplate(config Config, funcs FuncMapMappings, logger xlog.OptionalLogger) (TemplateQualifier, error)

NewTemplate creates a new html/template with templates in config dir and given functions registered by the FuncMapMappings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL