theme

package
v0.0.0-...-c336e2e Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrThemeMetaMissing means no meta file for this theme
	ErrThemeMetaMissing = errors.New("need add theme meta file")
	// ErrThemeOutdatedVersion means the theme is out-version
	ErrThemeOutdatedVersion = errors.New("theme need newer PuGo version")
)

Functions

This section is empty.

Types

type Meta

type Meta struct {
	Name string   `toml:"name"`
	Repo string   `toml:"repo"`
	URL  string   `toml:"url"`
	Date string   `toml:"date"`
	Desc string   `toml:"desc"`
	Tags []string `toml:"tags"`

	MinVersion string `toml:"min_version"`

	// Authors []*model.Author `toml:"author" ini:"-"`
	Refs []*Reference `toml:"ref"`

	License    string `toml:"license" `
	LicenseURL string `toml:"license_url"`
}

Meta is description of theme

func NewMeta

func NewMeta(data []byte) (*Meta, error)

NewMeta parses bytes to theme meta

func NewMetaFromFile

func NewMetaFromFile(file string) (*Meta, error)

NewMetaFromFile parses theme meta via file

type Reference

type Reference struct {
	Name string `toml:"name"`
	URL  string `toml:"url"`
	Repo string `toml:"repo"`
}

Reference is reference of user links

type Theme

type Theme struct {
	Meta *Meta
	// contains filtered or unexported fields
}

Theme maintains a sort of templates for whole site data

func New

func New(dir string) (*Theme, error)

New returns new theme with dir

func (*Theme) Dir

func (th *Theme) Dir() string

Dir get theme directory

func (*Theme) Execute

func (th *Theme) Execute(w io.Writer, name string, data interface{}) error

Execute executes template by name with data, write into a Writer

func (*Theme) Func

func (th *Theme) Func(key string, fn interface{})

Func add template func to theme

func (*Theme) Funcs

func (th *Theme) Funcs() template.FuncMap

Funcs return all template functions

func (*Theme) Len

func (th *Theme) Len() int

Len gets the number of templates in this theme

func (*Theme) Load

func (th *Theme) Load() error

Load loads templates

func (*Theme) Static

func (th *Theme) Static() string

Static gets static dirname in the theme

func (*Theme) StaticDir

func (th *Theme) StaticDir() string

StaticDir gets static dir in the theme

func (*Theme) Template

func (th *Theme) Template(name string) *template.Template

Template gets template by name

func (*Theme) Validate

func (th *Theme) Validate() error

Validate check theme meta is valid or not

Jump to

Keyboard shortcuts

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