fileloader

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTemplatesMap

func LoadTemplatesMap(
	config Config,
	templateLoader templates.TemplateLoader,
	logger log.Logger,
) (templates.Store, error)

LoadTemplatesMap load templates from directory.

Types

type Config

type Config struct {
	DirPath string
}

Config for templates.

type FileAssets

type FileAssets struct {
	// contains filtered or unexported fields
}

FileAssets type.

func NewFileAssets

func NewFileAssets(fileSystem http.FileSystem) *FileAssets

NewFileAssets constructor.

func (*FileAssets) Open

func (assets *FileAssets) Open(path string) (io.Reader, error)

Open file by path.

type FileAssetsLoader

type FileAssetsLoader struct{}

FileAssetsLoader type.

func NewFileAssetsLoader

func NewFileAssetsLoader() *FileAssetsLoader

NewFileAssetsLoader constructor.

func (*FileAssetsLoader) LoadAssets

func (fileAssetsLoader *FileAssetsLoader) LoadAssets(
	templateDirPath string,
	logger log.Logger,
) templates.Assets

LoadAssets FileSystem from assets dir.

type FileExamplesLoader

type FileExamplesLoader struct{}

FileExamplesLoader type.

func NewFileExamplesLoader

func NewFileExamplesLoader() *FileExamplesLoader

NewFileExamplesLoader constructor.

func (*FileExamplesLoader) LoadExamples

func (examplesLoader *FileExamplesLoader) LoadExamples(
	templateDirPath string,
	logger log.Logger,
) (templates.Examples, error)

LoadExamples by path.

type FileParamsLoader

type FileParamsLoader struct{}

FileParamsLoader load params from file.

func NewFileParamsLoader

func NewFileParamsLoader() *FileParamsLoader

NewFileParamsLoader constructor.

func (*FileParamsLoader) LoadParams

func (fileParamsLoader *FileParamsLoader) LoadParams(
	templateDirPath string,
	logger log.Logger,
) (*templates.Params, error)

LoadParams from templateDirPath.

type FileSchemaLoader

type FileSchemaLoader struct{}

FileSchemaLoader load JSON Schema from file system.

func NewFileSchemaLoader

func NewFileSchemaLoader() *FileSchemaLoader

NewFileSchemaLoader construct.

func (*FileSchemaLoader) LoadSchema

func (fileSchemaLoader *FileSchemaLoader) LoadSchema(
	templateDirPath string,
	logger log.Logger,
) (templates.Validator, error)

LoadSchema from templateDir.

type FileTemplateInstanceLoader

type FileTemplateInstanceLoader struct {
	// contains filtered or unexported fields
}

FileTemplateInstanceLoader load templates from file system.

func DefaultFileTemplateInstanceLoader

func DefaultFileTemplateInstanceLoader() *FileTemplateInstanceLoader

DefaultFileTemplateInstanceLoader create FileTemplateInstanceLoader with default list of template engine loaders.

func NewFileTemplateInstanceLoader

func NewFileTemplateInstanceLoader(
	templateInstanceLoaders ...TemplateInstanceLoader,
) *FileTemplateInstanceLoader

NewFileTemplateInstanceLoader create new FileTemplateInstanceLoader with defined template engine loader.

func (FileTemplateInstanceLoader) LoadTemplateInstance

func (instanceLoader FileTemplateInstanceLoader) LoadTemplateInstance(
	templateDirPath string,
	partName string,
	logger log.Logger,
) (templates.TemplateInstance, error)

LoadTemplateInstance iterate over template instance factory when it not return error.

type FileTemplateLoader

FileTemplateLoader load template from directory on file system.

func NewFileTemplateLoader

func NewFileTemplateLoader(
	templateInstanceLoader templates.TemplateInstanceLoader,
	schemaLoader templates.SchemaLoader,
	paramsLoader templates.ParamsLoader,
	assetsLoader templates.AssetsLoader,
	examplesLoader templates.ExamplesLoader,
) *FileTemplateLoader

NewFileTemplateLoader constructor.

func (*FileTemplateLoader) LoadTemplate

func (templateLoader *FileTemplateLoader) LoadTemplate(
	templatesDirPath string,
	templateName string,
	logger log.Logger,
) (*templates.Template, error)

LoadTemplate load template dir. nolint:funlen

type GoTemplate

type GoTemplate struct {
	*templatePkg.Template
	// contains filtered or unexported fields
}

GoTemplate wrap go template and JSON schema.

func NewGoTemplate

func NewGoTemplate(template *templatePkg.Template, logger log.Logger) *GoTemplate

NewGoTemplate constructor.

func (*GoTemplate) Render

func (gt *GoTemplate) Render(data interface{}) (string, error)

Render go template.

type GoTemplateInstanceLoader

type GoTemplateInstanceLoader struct{}

GoTemplateInstanceLoader load go template.

func (*GoTemplateInstanceLoader) LoadTemplateInstance

func (loader *GoTemplateInstanceLoader) LoadTemplateInstance(
	templateDirPath string,
	partName string,
	logger log.Logger,
) (templates.TemplateInstance, error)

LoadTemplateInstance go template partName from templateDirPath.

func (*GoTemplateInstanceLoader) TemplateName

func (loader *GoTemplateInstanceLoader) TemplateName(partName string) string

TemplateName return go template name.

func (*GoTemplateInstanceLoader) TemplateType

func (loader *GoTemplateInstanceLoader) TemplateType() string

TemplateType return go template type.

type MustacheTemplate

type MustacheTemplate struct {
	// contains filtered or unexported fields
}

MustacheTemplate engine.

func NewMustacheTemplate

func NewMustacheTemplate(
	template *mustache.Template,
	logger log.Logger,
) *MustacheTemplate

NewMustacheTemplate constructor.

func (*MustacheTemplate) Render

func (mt *MustacheTemplate) Render(data interface{}) (string, error)

Render mustache template.

type MustacheTemplateInstanceLoader

type MustacheTemplateInstanceLoader struct{}

MustacheTemplateInstanceLoader load mustache template.

func (*MustacheTemplateInstanceLoader) LoadTemplateInstance

func (loader *MustacheTemplateInstanceLoader) LoadTemplateInstance(
	templateDir string,
	partName string,
	logger log.Logger,
) (templates.TemplateInstance, error)

LoadTemplateInstance mustache partName template from templateDir.

func (*MustacheTemplateInstanceLoader) TemplateName

func (loader *MustacheTemplateInstanceLoader) TemplateName(partName string) string

TemplateName return mustache template name.

func (*MustacheTemplateInstanceLoader) TemplateType

func (loader *MustacheTemplateInstanceLoader) TemplateType() string

TemplateType return mustache template type.

type StaticTemplate

type StaticTemplate struct {
	// contains filtered or unexported fields
}

StaticTemplate copy HTML on render.

func NewStaticTemplate

func NewStaticTemplate(
	payload string,
	logger log.Logger,
) *StaticTemplate

NewStaticTemplate constructor.

func (*StaticTemplate) Render

func (st *StaticTemplate) Render(_ interface{}) (string, error)

Render static template.

type StaticTemplateInstanceLoader

type StaticTemplateInstanceLoader struct{}

StaticTemplateInstanceLoader load static template.

func (*StaticTemplateInstanceLoader) LoadTemplateInstance

func (loader *StaticTemplateInstanceLoader) LoadTemplateInstance(
	templateDir string,
	partName string,
	logger log.Logger,
) (templates.TemplateInstance, error)

LoadTemplateInstance static partName template from templateDir.

func (*StaticTemplateInstanceLoader) TemplateName

func (loader *StaticTemplateInstanceLoader) TemplateName(partName string) string

TemplateName return static template name.

func (*StaticTemplateInstanceLoader) TemplateType

func (loader *StaticTemplateInstanceLoader) TemplateType() string

TemplateType return static template type.

type TemplateFileNotFoundError

type TemplateFileNotFoundError struct {
	// contains filtered or unexported fields
}

TemplateFileNotFoundError returned when template not founded on disk.

func NewTemplateFileNotFoundError

func NewTemplateFileNotFoundError(
	templateType string,
	templatePath string,
) *TemplateFileNotFoundError

NewTemplateFileNotFoundError construct new TemplateFileNotFoundError.

func (*TemplateFileNotFoundError) Error

func (err *TemplateFileNotFoundError) Error() string

func (*TemplateFileNotFoundError) Is

func (err *TemplateFileNotFoundError) Is(otherErr error) bool

Is for errors.Is.

type TemplateInstanceLoader

type TemplateInstanceLoader interface {
	LoadTemplateInstance(
		templateDirPath string,
		partName string,
		logger log.Logger,
	) (templates.TemplateInstance, error)
	TemplateType() string
	TemplateName(partName string) string
}

TemplateInstanceLoader interface.

Jump to

Keyboard shortcuts

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