Documentation ¶
Overview ¶
Package templates used for load templates from file system and render template to HTML
Index ¶
- type Assets
- type AssetsLoader
- type Data
- type DefaultRenderer
- type ExampleNotExistsError
- type Examples
- type ExamplesLoader
- type InvalidDataSchemaError
- type JSONSchemaValidator
- type List
- type MapStore
- type Name
- type PDFParams
- func (params *PDFParams) GetLandscape() *bool
- func (params *PDFParams) GetMarginBottom() *float64
- func (params *PDFParams) GetMarginLeft() *float64
- func (params *PDFParams) GetMarginRight() *float64
- func (params *PDFParams) GetMarginTop() *float64
- func (params *PDFParams) GetPaperHeight() *float64
- func (params *PDFParams) GetPaperWidth() *float64
- func (params *PDFParams) GetPreferCSSPageSize() *bool
- func (params *PDFParams) GetPrintBackground() *bool
- func (params *PDFParams) GetScale() *float64
- type Params
- type ParamsLoader
- type RenderResult
- type Renderer
- type SchemaLoader
- type Store
- type Template
- type TemplateInstance
- type TemplateInstanceLoader
- type TemplateLoader
- type TemplateNotExistsError
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetsLoader ¶
AssetsLoader interface.
type DefaultRenderer ¶
type DefaultRenderer struct {
// contains filtered or unexported fields
}
DefaultRenderer is default implementation of TemplatesRender.
func NewDefaultRenderer ¶
func NewDefaultRenderer( store Store, tracerProvider trace.TracerProvider, ) *DefaultRenderer
NewDefaultRenderer constructor.
func (*DefaultRenderer) RenderHTMLExample ¶
func (render *DefaultRenderer) RenderHTMLExample( ctx context.Context, templateName Name, exampleName string, ) ( *RenderResult, error, )
RenderHTMLExample template by name and example.
func (*DefaultRenderer) RenderHTMLWithData ¶
func (render *DefaultRenderer) RenderHTMLWithData( ctx context.Context, templateName Name, data Data, ) ( *RenderResult, error, )
RenderHTMLWithData template by name and data.
type ExampleNotExistsError ¶
type ExampleNotExistsError struct {
// contains filtered or unexported fields
}
ExampleNotExistsError returned on DefaultRenderer.RenderHTMLExample.
func NewExampleNotExistsError ¶
func NewExampleNotExistsError(exampleName string) *ExampleNotExistsError
NewExampleNotExistsError construct new ExampleNotExistsError.
func (*ExampleNotExistsError) Error ¶
func (err *ExampleNotExistsError) Error() string
func (*ExampleNotExistsError) Is ¶
func (err *ExampleNotExistsError) Is(otherErr error) bool
Is implements errors.Is.
type ExamplesLoader ¶
type ExamplesLoader interface { LoadExamples( templateDirPath string, logger log.Logger, ) (Examples, error) }
ExamplesLoader interface.
type InvalidDataSchemaError ¶
type InvalidDataSchemaError struct{}
InvalidDataSchemaError returned by Validator when provided data is not valid.
func (*InvalidDataSchemaError) Error ¶
func (err *InvalidDataSchemaError) Error() string
func (*InvalidDataSchemaError) Is ¶
func (err *InvalidDataSchemaError) Is(otherError error) bool
Is used by errors.Is.
type JSONSchemaValidator ¶
type JSONSchemaValidator struct {
// contains filtered or unexported fields
}
JSONSchemaValidator validate data with json schema.
func NewJSONSchemaValidator ¶
func NewJSONSchemaValidator(rawSchema []byte) (*JSONSchemaValidator, error)
NewJSONSchemaValidator construct new JSONSchemaValidator.
func (*JSONSchemaValidator) MarshalJSON ¶
func (validator *JSONSchemaValidator) MarshalJSON() ([]byte, error)
MarshalJSON return raw schema representation. nolint:unparam
func (*JSONSchemaValidator) ValidateData ¶
func (validator *JSONSchemaValidator) ValidateData(ctx context.Context, data interface{}) error
ValidateData match provided data with JSON schema.
type PDFParams ¶
type PDFParams struct { Landscape *bool `json:"landscape"` PrintBackground *bool `json:"printBackground"` PreferCSSPageSize *bool `json:"preferCSSPageSize"` Scale *float64 `json:"scale"` PaperWidth *float64 `json:"paperWidth"` PaperHeight *float64 `json:"paperHeight"` MarginTop *float64 `json:"marginTop"` MarginBottom *float64 `json:"marginBottom"` MarginLeft *float64 `json:"marginLeft"` MarginRight *float64 `json:"marginRight"` }
PDFParams definition.
func (*PDFParams) GetLandscape ¶
GetLandscape return params Landscape.
func (*PDFParams) GetMarginBottom ¶
GetMarginBottom return params MarginBottom.
func (*PDFParams) GetMarginLeft ¶
GetMarginLeft return params MarginLeft.
func (*PDFParams) GetMarginRight ¶
GetMarginRight return params MarginRight.
func (*PDFParams) GetMarginTop ¶
GetMarginTop return params MarginTop.
func (*PDFParams) GetPaperHeight ¶
GetPaperHeight return params PaperHeight.
func (*PDFParams) GetPaperWidth ¶
GetPaperWidth return params PaperWidth.
func (*PDFParams) GetPreferCSSPageSize ¶
GetPreferCSSPageSize return params PreferCSSPageSize.
func (*PDFParams) GetPrintBackground ¶
GetPrintBackground return params PrintBackground.
type ParamsLoader ¶
type ParamsLoader interface { LoadParams( templateDirPath string, logger log.Logger, ) (*Params, error) }
ParamsLoader interface.
type RenderResult ¶
RenderResult returned by Renderer interface.
type Renderer ¶
type Renderer interface { RenderHTMLWithData( ctx context.Context, templateName Name, data Data, ) (*RenderResult, error) RenderHTMLExample( ctx context.Context, templateName Name, exampleName string, ) (*RenderResult, error) }
Renderer engine interface.
type SchemaLoader ¶
type SchemaLoader interface { LoadSchema( templateDirPath string, logger log.Logger, ) (Validator, error) }
SchemaLoader interface.
type Template ¶
type Template struct { Name Body TemplateInstance Header TemplateInstance *Params Validator Validator Assets Examples }
Template wrap TemplateInstance with Schema.
type TemplateInstance ¶
TemplateInstance render template with data.
type TemplateInstanceLoader ¶
type TemplateInstanceLoader interface { LoadTemplateInstance( templateDirPath string, partName string, logger log.Logger, ) (TemplateInstance, error) }
TemplateInstanceLoader interface.
type TemplateLoader ¶
type TemplateLoader interface { LoadTemplate( templateDirPath string, templateName string, logger log.Logger, ) (*Template, error) }
TemplateLoader interface.
type TemplateNotExistsError ¶
type TemplateNotExistsError struct {
// contains filtered or unexported fields
}
TemplateNotExistsError returned from Store.Fetch.
func NewTemplateNotExistsError ¶
func NewTemplateNotExistsError(templateName Name) *TemplateNotExistsError
NewTemplateNotExistsError construct new TemplateNotExistsError.
func (*TemplateNotExistsError) Error ¶
func (err *TemplateNotExistsError) Error() string
func (*TemplateNotExistsError) Is ¶
func (err *TemplateNotExistsError) Is(otherErr error) bool
Is implement errors.Is.