docs

package
v0.0.0-...-4182e41 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PageDefaultAcceptHeader  = "text/html"
	PageAcceptHeader         = "application/void+page"
	PageDiffAcceptHeader     = "application/void+page_diff"
	PageJSONAcceptHeader     = "application/void+page_json"
	PageJSONDiffAcceptHeader = "application/void+page_json_diff"
)

Variables

This section is empty.

Functions

func ServePage

func ServePage(p Page, decoder DataDecoder) nhttp.ContextHandler

ServePage handles serving a page as html or depending on accept header renders either

func ServePageOptions

func ServePageOptions() nhttp.ContextHandler

Types

type Changes

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

Changes manages a giving page and allows you to render a page latest content from new data and a diff which is generated by comparing the latest render with the previous cached render.

func NewChanges

func NewChanges(p *Page) *Changes

func (*Changes) Render

func (pc *Changes) Render(d Data) *markup.Node

Render renders new markup.Node from existing page.

The markup node is pure, which means it's the complete picture generated from a Page object.

func (*Changes) RenderDiff

func (pc *Changes) RenderDiff(d Data) *markup.Node

RenderDiff renders new markup.Node from existing page which is reconciled with it's previous render.

The markup node is pure, which means it's the complete picture generated from a Page object.

type Component

type Component interface {
	Mount(SectionDocument, Data)
}

Component represents an encapsulated part of a page which is reusable for creating UI elements.

type ComponentFunc

type ComponentFunc func(SectionDocument, Data)

ComponentFunc provides an implementation of a Component on a function type, allowing functional components.

func (ComponentFunc) Mount

func (fn ComponentFunc) Mount(pg SectionDocument, d Data)

Mount implements Component interface.

type Data

type Data interface{}

type DataDecoder

type DataDecoder interface {
	Decode(io.Reader) (interface{}, error)
}

type Document

type Document interface {
	Render(data interface{}) *markup.Node
}

Document represent a render target which produces a markup.Node which can be used to generate html/xml markup as response.

type Page

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

Page implements the Document interface and represents a single unique html page.

func NewPage

func NewPage(pageName string, fns ...func(*Page)) *Page

func (*Page) AddComponent

func (p *Page) AddComponent(component Component)

func (*Page) Name

func (p *Page) Name() string

func (*Page) Render

func (p *Page) Render(data interface{}) *markup.Node

Render renders all attached components to the root document for giving page.

type SectionDocument

type SectionDocument interface {
	AddComponent(component Component)
}

SectionDocument represents a source which houses components which would be rendered as they are added into the page.

All components are positional, meaning where you add them will be where they occur within the page.

if you want more control then use a single component to embody more flexibility in components position.

type VoidRequest

type VoidRequest struct {
	Data    []byte      `json:"data"`
	Session VoidSession `json:"_session"`
}

type VoidSession

type VoidSession struct {
}

Jump to

Keyboard shortcuts

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