transformer

package
v0.0.0-...-4eaec5d Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPage = errors.New("no page.Page with path found")

ErrNoPage is returned when a page.Page that doesn't exist is referenced.

Functions

This section is empty.

Types

type Bundle

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

Bundle is a Transformer which bundles all referenced CSS and JS page.Pages referenced in a page.Page.

func NewBundle

func NewBundle(ps []page.Page) *Bundle

NewBundle that has access to references in the page.Pages.

func (Bundle) Transform

func (t Bundle) Transform(p page.Page) (page.Page, error)

Transform the page.Page by replacing all referenced CSS and JS page.Pages with their page.Pages.

Returns ErrNopage.Page if a referenced page.Page can't be found or if bundling fails.

type Func

type Func func(page.Page) (page.Page, error)

Func wraps functions into Transformers.

func (Func) Transform

func (f Func) Transform(p page.Page) (page.Page, error)

Transform the page.Page by applying the function.

type Gzip

type Gzip struct{}

Gzip is a Transformer which gzips page.Pages.

func NewGzip

func NewGzip() Gzip

NewGzip Transformer.

func (Gzip) Transform

func (t Gzip) Transform(p page.Page) (page.Page, error)

Transform returns the gzipped page.Page.

Returns an error if the page.Page couldn't be gzipped.

type Minify

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

Minify is a Transformer which minifies page.Pages.

func NewMinify

func NewMinify() *Minify

NewMinify which can HTML, CSS, JS, and XML files.

func (Minify) Transform

func (t Minify) Transform(p page.Page) (page.Page, error)

Transform the page.Page by minifying it if it is an HTML, CSS, JS, and XML file and skipping it otherwise.

Returns an error if the page.Page couldn't be minified.

type Transformer

type Transformer interface {
	// Transform the page.Page.
	//
	// Returns an error if the transformation couldn't be applied.
	Transform(page.Page) (page.Page, error)
}

Transformer creates a new page.Page from the given page.Page.

Jump to

Keyboard shortcuts

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