html

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Extension      = ".htm"
	BlocksPrefix   = "blocks/"
	PartialsPrefix = "partials/"
	LayoutsPrefix  = "layouts/"
	PagesPrefix    = "pages/"

	DefaultLanguage     = "en"
	DefaultLayout       = "default"
	DefaultRobotsIndex  = false
	DefaultRobotsFollow = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

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

Block represents a block in a template.

func NewBlock

func NewBlock(set *pongo2.TemplateSet, name string, content []byte, minify bool) (b *Block, err error)

NewBlock creates a new Block from the given content.

func (*Block) Render

func (b *Block) Render(writer io.Writer, variables pongo2.Context) error

Render renders the block with the given variables.

type Blocks

type Blocks map[string]*Block

type Config

type Config struct {
	Directory string         `json:"directory" yaml:"Directory"`
	Debug     bool           `json:"debug"     yaml:"Debug"`
	Minify    bool           `json:"minify"    yaml:"Minify"`
	Cache     bool           `json:"cache"     yaml:"Cache"`
	Variables pongo2.Context `json:"variables" yaml:"Variables"`
	// contains filtered or unexported fields
}

Config represents a HTML renderer configuration.

type Html

type Html struct {
	Blocks   Blocks
	Partials Partials
	Layouts  Layouts
	Pages    Pages
	// contains filtered or unexported fields
}

Html represents a HTML renderer.

func NewRender

func NewRender(config *Config) *Html

NewRender creates a new Html from the given directory.

func (*Html) Load

func (h *Html) Load() error

Load loads all templates from the given directory.

func (*Html) Render

func (h *Html) Render(writer io.Writer, template string, variables any, l ...string) error

Render renders the given template with the given variables.

type Layout

type Layout struct {
	Variables pongo2.Context `yaml:"Variables"`
	// contains filtered or unexported fields
}

Layout represents a layout in a template.

func NewLayout

func NewLayout(set *pongo2.TemplateSet, name string, content []byte, minify bool) (l *Layout, err error)

NewLayout creates a new Layout from the given content.

func (*Layout) Render

func (l *Layout) Render(writer io.Writer, variables pongo2.Context) error

Render renders the layout with the given page and variables.

type Layouts

type Layouts map[string]*Layout

type Page

type Page struct {
	Title                  string         `yaml:"Title"`
	Description            string         `yaml:"Description"`
	Keywords               []string       `yaml:"Keywords"`
	Language               string         `yaml:"Language"`
	Path                   string         `yaml:"Path"`
	Layout                 string         `yaml:"Layout"`
	Author                 string         `yaml:"Author"`
	RobotsIndex            bool           `yaml:"RobotsIndex"`
	RobotsFollow           bool           `yaml:"RobotsFollow"`
	Draft                  bool           `yaml:"Draft"`
	Static                 bool           `yaml:"Static"`
	SitemapChangeFrequency string         `yaml:"SitemapChangeFrequency"`
	SitemapPriority        float64        `yaml:"SitemapPriority"`
	CreatedAt              time.Time      `yaml:"CreatedAt"`
	UpdatedAt              time.Time      `yaml:"UpdatedAt"`
	Variables              pongo2.Context `yaml:"Variables"`
	// contains filtered or unexported fields
}

Page represents a page in a template.

func NewPage

func NewPage(set *pongo2.TemplateSet, name string, content []byte, minify bool) (p *Page, err error)

NewPage creates a new Page from the given content.

func (*Page) Render

func (p *Page) Render(writer io.Writer, variables pongo2.Context) error

Render renders the page with the given variables.

type Pages

type Pages map[string]*Page

type Partial

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

Partial represents a partial in a template.

func NewPartial

func NewPartial(set *pongo2.TemplateSet, name string, content []byte, minify bool) (p *Partial, err error)

NewPartial creates a new Partial from the given content.

func (*Partial) Render

func (p *Partial) Render(writer io.Writer, variables pongo2.Context) error

Render renders the partial with the given variables.

type Partials

type Partials map[string]*Partial

Jump to

Keyboard shortcuts

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