template

package
v0.0.0-...-5b6c26d Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is a directory that contains multiple templates.

func OpenStore

func OpenStore(dir string) (Store, error)

OpenStore returns a new Store for the passed dir. It will also create the dir if it doesn't exist.

func (*Store) Create

func (ts *Store) Create(key string, t *Template) error

Create copies a template into the Store and stores it under the passed key. If there are any errors this might leave a partially created template in the store.

func (*Store) Delete

func (ts *Store) Delete(key string) error

Delete removes a template from the store

func (*Store) Get

func (ts *Store) Get(key string) (Template, error)

Get returns the template that is store under the passed key. If the template cannot be loaded it will return an error

func (*Store) List

func (ts *Store) List() (map[string]*Template, error)

List lists all the templates that are in a Store. If there is a template that cannot be parsed it will return an error.

func (*Store) Replace

func (ts *Store) Replace(key string, t *Template) error

Replace is a helper method that calls Delete with the passed key and then Create with the passed key and template.

type Template

type Template struct {
	// The Templates metadata
	Meta meta `yaml:"meta"`
	// Our internal representation of the Questions to ask
	Questions []question `yaml:"questions"`
	// contains filtered or unexported fields
}

Template is our representation of a set of templates and questions.

func New

func New(dir string) (Template, error)

New take a directory containing a template, parses it and returns a new Tempalate.

func (*Template) Execute

func (t *Template) Execute(targetRoot string, data map[string]interface{}) error

Execute applies the template to a given directory using the data that has been passed in.

func (*Template) GetQuestions

func (t *Template) GetQuestions() []*survey.Question

GetQuestions takes the templates internal representation of the Template's questions and converts them into a format that can be used by survey.

Jump to

Keyboard shortcuts

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