interpolate

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

Interpolate

This package offers tools to interpolate files at runtime using go text/template.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File is the file magic sauce here.

This will implement the http.File interface and can be used in place of a good old http.File in the standard library.

However we can also call proprietary methods on an IFile so we can do the hacky ass interpolating we want to do so we can have dynamic content in our static workflow.

Why? Because Kris Nóva is insane.

type File interface

io.Closer
io.Reader
io.Seeker
Readdir(count int) ([]fs.FileInfo, error)
Stat() (fs.FileInfo, error)

func NewFile

func NewFile(file http.File) *File

NewFile essentially "extends" the base http.File

Everything you can do with an http.File you can now also do with an

func (*File) Bytes

func (f *File) Bytes() []byte

func (*File) Close

func (f *File) Close() error

func (*File) Interpolate

func (f *File) Interpolate(values interface{}) (*File, error)

func (*File) Read

func (f *File) Read(p []byte) (n int, err error)

func (*File) Readdir

func (f *File) Readdir(count int) ([]fs.FileInfo, error)

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

func (*File) Stat

func (f *File) Stat() (fs.FileInfo, error)

func (*File) Write

func (f *File) Write(p []byte) (n int, err error)

Write is used by text/template to write the interpolated bytes to the data structure.

Ideally we shouldn't ever be using this for anything other than that.

Write will always append... ye be warned... here be dragons...

Jump to

Keyboard shortcuts

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