routemap

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ModifiedRoutemap

func ModifiedRoutemap(file io.Reader, templates, handlers []Missing) ([]byte, error)

ModifiedRoutemap will read the lines of a routemap and insert missing content at the releveant locations

func ProcessRoutemap

func ProcessRoutemap(tree *toml.Tree, templatePath string, bindResources bool) (routes PageRoutes, templates []Missing, handlers []Missing, err error)

ProcessRoutemap will unmarshal and validate a TOML routemap. This will keep track of missing template and handler values.

func TemplateDataForRoutes

func TemplateDataForRoutes(page PageRoutes, missTpl []Missing, missHlr []Missing) (
	entries []generate.Entry,
	routes []generate.Route,
	templates []generate.HTMLTemplate,
	handlers []generate.Handler,
	err error,
)

TemplateDataForRoutes will take hierarchical definition of views and flatten to data for rendering in the templates

Types

type Missing

type Missing struct {
	Ref           string
	Position      toml.Position
	InsertContent string
}

Missing is a missing value in the TOML file tree, it pairs the route view data with the position reference in the source TOML file

type PageRoutes

type PageRoutes struct {
	RouteView
	EntryPoint string `toml:"_entrypoint"`
}

PageRoutes is the top level view for a site page, it includes a URI and golang package namespace

type RouteView

type RouteView struct {
	Ref      string   `toml:"_ref"`
	Default  bool     `toml:"_default"`
	Doc      string   `toml:"_doc"`
	Path     string   `toml:"_path"`
	Template string   `toml:"_template"`
	Handler  string   `toml:"_handler"`
	Method   string   `toml:"_method"`
	Fragment bool     `toml:"_fragment"`
	Partial  bool     `toml:"_partial"`
	Merge    string   `toml:"_merge"`
	Includes []string `toml:"_includes"`
	Blocks   []TemplateBlock
	Block    string
}

RouteView is a handler + template pair corresponding to a single partial, it may contain a number of slots available for extention by sub views

type TemplateBlock

type TemplateBlock struct {
	Name  string
	Views []RouteView
}

TemplateBlock is a named child template slot within in a go template. Views is a list of RouteViews directly defined for that slot

Jump to

Keyboard shortcuts

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