snippy

package
v0.0.0-...-618b02f Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 14 Imported by: 0

README

Snippy

Snippy

Motivation

Execute go templates in few lines

Status

Project is in pre-alpha status.

Getting started

One template:

snippy.
    NewSnippy("output/dir").
    Prepare("templates/input.tmpl", data, "output.file").
    Do()

Batch:

	if err := snippy.Run(
		snp.Prepare("templates/root/openapi.tmpl", item, "api/openapi.yaml"),
		snp.Prepare("templates/root/gearbox_main.tmpl", item, "cmd/gearbox/main.go"),
		snp.Prepare("templates/root/app.tmpl", item, "cmd/gearbox/app.go"),
	); err != nil {
		log.Panicln(err)
	}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(templates ...Doer) error

Types

type Doer

type Doer interface {
	Do() error
}

type Exported

type Exported interface {
	Exported() map[string][]string
	ResetExported()
	Name() string
}

type Snippy

type Snippy struct {
	WD           string
	TemplatePath string
	OutputDir    string
	OutputFile   string
	Module       string
	Data         interface{}
	KV           map[string]string
	ExporteData  map[string][]string
	CamelCase    func(s string) string
	LowCamelCase func(s string) string
	SnakeCase    func(s string) string
	KebabCase    func(s string) string
	// contains filtered or unexported fields
}

func NewSnippy

func NewSnippy(fs embed.FS, outputDir string) Snippy

func (Snippy) Do

func (s Snippy) Do() error

func (Snippy) Exported

func (s Snippy) Exported() map[string][]string

func (Snippy) Import

func (s Snippy) Import(value string) string

func (Snippy) Imports

func (s Snippy) Imports() string

func (Snippy) Name

func (s Snippy) Name() string

func (Snippy) Prepare

func (s Snippy) Prepare(templatePath string, withValue interface{}, toPath ...string) Doer

func (*Snippy) ResetExported

func (s *Snippy) ResetExported()

func (Snippy) UnzipHttp

func (s Snippy) UnzipHttp(url string, targetDir string)

Jump to

Keyboard shortcuts

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