Documentation ¶
Index ¶
- func CreateOrOverwrite(path string, content []byte) error
- func DefaultDataDir() string
- func PickFile(dir, message string) string
- func PickTemplate(message string) (name string)
- func ReadDir(path string) []string
- func Setup()
- func SingleFromFile() error
- func StringToFile(content string, destination string) error
- func Teardown()
- type CFG
- type Data
- type Template
- type Templates
- func (ts *Templates) Add(newTmpl Template) error
- func (ts Templates) GetByName(name string) (Template, error)
- func (ts *Templates) NameExists(name string) bool
- func (ts Templates) Names() []string
- func (ts *Templates) Remove(name string) error
- func (ts Templates) Save() error
- func (ts *Templates) Update(t Template) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateOrOverwrite ¶
CreateOrOverwrite writes to a file. Create if it doesn't exist, replace if it does. Existing files will overwritten.
func DefaultDataDir ¶
func DefaultDataDir() string
DefaultDataDir returns path to the directory containing a user's templates.
func PickTemplate ¶
PickTemplate lets the user select a template and returns its name.
func Setup ¶
func Setup()
Setup creates all files & folders used by tmpl. Should be called directly after installing.
func SingleFromFile ¶
func SingleFromFile() error
SingleFromFile creates a new single-file template from an existing file.
func StringToFile ¶
StringToFile writes a string to a new or existing file. Existing files will overwritten.
Types ¶
type CFG ¶
type CFG struct { TemplatesDir string // Path to the folder where a user's templates are stored. Editor string // Text editor used for editing templates. }
CFG contains config variables for tmpl.
type Template ¶
type Template struct { Name string // Name used to identify the template. These are unique. MultiFile bool // True if the template is for more than a single file. FileName string // Name to use when creating a copy of this template. Content string // The content of the template itself. Data []string // Data used for dynamic template content. }
Template is a single file.
func (Template) GetContent ¶
GetContent for a template. Prompts for variable values if the template has any.
type Templates ¶
type Templates struct {
T []Template `json:"templates"`
}
Templates models a user's existing templates.
func GetTemplates ¶
GetTemplates returns the user's templates.
func (Templates) GetByName ¶
GetByName returns a template with a given name and an error if no template is found.
func (*Templates) NameExists ¶
NameExists checks to see if a given name is already being used for a template.