render

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package render

Package render

Package render

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstCharacterTitle

func FirstCharacterTitle(str string) string

func FuncMap

func FuncMap() map[string]any

func Include

func Include(
	template string,
	templateData any,
	templateContextData TemplateContextData,
) string

include allows to include a template allowing to use filter Eg: {{ include "template.tpl" | indent 4 }}

func MustInclude

func MustInclude(
	templateName string,
	templateData any,
	templateContextData TemplateContextData,
) (output string, err error)

func ToSnakeCase

func ToSnakeCase(str string) string

Types

type TemplateContext

type TemplateContext struct{}

func NewTemplateContext

func NewTemplateContext() (templateContext *TemplateContext)

func (*TemplateContext) Init

func (templateContext *TemplateContext) Init(
	templateDirs []string,
	templateFile string,
	data any,
	funcMap map[string]any,
) (*TemplateContextData, error)

func (*TemplateContext) Render

func (*TemplateContext) Render(
	templateContextData *TemplateContextData,
	templateName string,
) (string, error)

func (*TemplateContext) RenderFromTemplateContent

func (*TemplateContext) RenderFromTemplateContent(
	templateContextData *TemplateContextData,
	templateContent string,
) (codeStr string, err error)

func (*TemplateContext) RenderFromTemplateName

func (templateContext *TemplateContext) RenderFromTemplateName(
	templateContextData *TemplateContextData,
) (code string, err error)

type TemplateContextData

type TemplateContextData struct {
	TemplateContext TemplateContextInterface
	TemplateName    *string
	Template        templateInterface
	RootData        any
	Data            any
}

type TemplateContextInterface

type TemplateContextInterface interface {
	Render(
		templateContextData *TemplateContextData,
		templateName string,
	) (string, error)
	RenderFromTemplateContent(
		templateContextData *TemplateContextData,
		templateContent string,
	) (codeStr string, err error)
}

Jump to

Keyboard shortcuts

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