Documentation ¶
Index ¶
- Constants
- func CreateNodes(links []Link) []*html.Node
- func Do(c *fiber.Ctx, cfg Config, doc *Document) error
- func Template(config Config, name string, bind interface{}, layouts ...string) fiber.Handler
- type Config
- type Document
- type Fragment
- func (f *Fragment) Deferred() bool
- func (f *Fragment) Element() *goquery.Selection
- func (f *Fragment) Fallback() string
- func (f *Fragment) HtmlFragment() *HtmlFragment
- func (f *Fragment) ID() string
- func (f *Fragment) Links() []*html.Node
- func (f *Fragment) Method() string
- func (f *Fragment) Primary() bool
- func (f *Fragment) Ref() string
- func (f *Fragment) Resolve() ResolverFunc
- func (f *Fragment) Src() string
- func (f *Fragment) Timeout() time.Duration
- type Header
- type HtmlFragment
- type Link
- type Resolver
- type ResolverFunc
Constants ¶
const ( StyleSheet = "stylesheet" Script = "script" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Filter defines a function to skip the middleware. // Optional. Default: nil Filter func(*fiber.Ctx) bool // FilterResponse defines a function to filter the responses // from the fragment sources. FilterResponse func(*fasthttp.Response) *fasthttp.Response // FilterRequest defines a function to filter the request // to the fragment sources. FilterRequest func(*fasthttp.Request) *fasthttp.Request // ErrorHandler defines a function which is executed // It may be used to define a custom error. // Optional. Default: 401 Invalid or expired key ErrorHandler fiber.ErrorHandler // FilterHead defines a function to filter the new // nodes in the <head> of the document passed by the LINK header entity. FilterHead func([]*html.Node) []*html.Node // DefaultHost defines the host to use, // if no host is set on a fragment. // Optional. Default: localhost:3000 DefaultHost string }
Config ...
type Document ¶
Document ...
func (*Document) HtmlFragment ¶ added in v0.2.0
func (d *Document) HtmlFragment() *HtmlFragment
Fragments is returning the selection of fragments from an HTML page.
func (*Document) SetStatusCode ¶
SetStatusCode is setting the HTTP status code for the document.
func (*Document) StatusCode ¶
StatusCode is getting the HTTP status code for the document.
type Fragment ¶
type Fragment struct {
// contains filtered or unexported fields
}
Fragment is a <fragment> in the <header> or <body> of a HTML page.
func FromSelection ¶
FromSelection creates a new fragment from a fragment selection in the DOM.
func (*Fragment) HtmlFragment ¶ added in v0.2.0
func (f *Fragment) HtmlFragment() *HtmlFragment
HtmlFragment returns embedded fragments of HTML.
func (*Fragment) Links ¶
Links returns the new nodes that go in the head via the LINK HTTP header entity.
func (*Fragment) Primary ¶
Primary denotes a fragment as responsible for setting the response code of the entire HTML page.
func (*Fragment) Resolve ¶
func (f *Fragment) Resolve() ResolverFunc
Resolve is resolving all needed data, setting headers and the status code.
type HtmlFragment ¶ added in v0.2.0
HtmlFragment is representation of HTML fragments.
func NewHtmlFragment ¶ added in v0.2.0
func NewHtmlFragment(root *html.Node) (*HtmlFragment, error)
NewHtmlFragment creates a new fragment of HTML.
func (*HtmlFragment) AppendHead ¶ added in v0.2.1
func (d *HtmlFragment) AppendHead(ns ...*html.Node)
AppendHead ...
func (*HtmlFragment) Fragment ¶ added in v0.2.0
func (h *HtmlFragment) Fragment() *goquery.Document
Document get the full document representation of the HTML fragment.
func (*HtmlFragment) Fragments ¶ added in v0.2.0
func (h *HtmlFragment) Fragments() (map[string]*Fragment, error)
Fragments is returning the selection of fragments from an HTML page.
func (*HtmlFragment) Html ¶ added in v0.2.0
func (h *HtmlFragment) Html() (string, error)
Html creates the HTML output of the created document.