placesmap

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

package placesmap provides a places.Mapper to allow embedding of templates, escaping etc

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPrefix = errors.New("prefix does not match the regular expression ^[a-z]+$")
View Source
var HTMLEscape = MapFunc(html.EscapeString)
View Source
var UrlEscape = MapFunc(url.QueryEscape)

Functions

This section is empty.

Types

type Empty

type Empty struct{}

Empty is a places.Mapper that always returns an empty string

func (Empty) Map

func (e Empty) Map(string) string

type HTMLTemplate

type HTMLTemplate struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewHTMLTemplate

func NewHTMLTemplate(rs *ReadSeekerMap) *HTMLTemplate

func (*HTMLTemplate) NewMapper

func (h *HTMLTemplate) NewMapper(m map[string]places.Mapper) *HTMLTemplateMapper

type HTMLTemplateMapper

type HTMLTemplateMapper struct {
	sync.Mutex
	*HTMLTemplate
	// contains filtered or unexported fields
}

func (*HTMLTemplateMapper) Map

func (h *HTMLTemplateMapper) Map(input string) string

type Map

type Map interface {
	places.Mapper

	// Add registers a mapper in the registry for the given prefix
	// If there is already a mapper for the given prefix, it will be overwritten
	// If prefix does not conform to the regular expression ^[a-z]+$, ErrInvalidPrefix is returned
	Add(prefix string, mapper places.Mapper) error
}

Map is a registry of places.Mappers and itself a places.Mapper

func New

func New() Map

New returns a new Map that is not safe for concurrent use.

func NewConcurrent

func NewConcurrent() Map

NewConcurrent returns a new Map that is safe for concurrent use.

type MapFunc

type MapFunc func(string) string

MapFunc is a func implementing places.Mapper

func (MapFunc) Map

func (m MapFunc) Map(placeholder string) string

type MapperAlreadyExistsError

type MapperAlreadyExistsError string

func (MapperAlreadyExistsError) Error

func (m MapperAlreadyExistsError) Error() string

type NMapper

type NMapper interface {
	places.Mapper
	NMap(n int, sub string) places.Mapper
	Len() int
}

type ReadSeekerAlreadyExistsError

type ReadSeekerAlreadyExistsError string

func (ReadSeekerAlreadyExistsError) Error

type ReadSeekerMap

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

ReadSeekerMap is a map of strings to io.ReadSeeker that may be used concurrently

func NewReadSeekerMap

func NewReadSeekerMap() *ReadSeekerMap

NewReadSeekerMap returns a

func (*ReadSeekerMap) Add

func (r *ReadSeekerMap) Add(name string, rs io.ReadSeeker) error

Add adds an io.ReadSeeker for the given name. If there is already a ReadSeeker defined for the given name, an error is returned. There are no restrictions for the name

func (*ReadSeekerMap) Map

func (r *ReadSeekerMap) Map(name string) (val string)

type RootDoesNotExistError

type RootDoesNotExistError string

func (RootDoesNotExistError) Error

func (r RootDoesNotExistError) Error() string

type RootIsNotDirectoryError

type RootIsNotDirectoryError string

func (RootIsNotDirectoryError) Error

func (r RootIsNotDirectoryError) Error() string

type Self

type Self string

func (Self) Map

func (s Self) Map(placeholder string) string

Self is a places.Mapper that always returns the placeholder prefixed by the value of Self

type String

type String string

Empty is a places.Mapper that always returns the string itself

func (String) Map

func (s String) Map(string) string

type TemplateLoader

type TemplateLoader struct {
	*ReadSeekerMap
	// contains filtered or unexported fields
}

TemplateLoader loads templates recursively from a root directory for a given file extension

func NewTemplateLoader

func NewTemplateLoader(rootDir string, extension string, ignoreDirs *regexp.Regexp) *TemplateLoader

func (*TemplateLoader) Load

func (l *TemplateLoader) Load() (*ReadSeekerMap, error)

Jump to

Keyboard shortcuts

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