noqcks / gucci

Templating on the command line with sprig.
MIT License
88 stars 20 forks source link

Use gucci as a library? #25

Closed till closed 4 years ago

till commented 4 years ago

Hey!

First off, thanks for creating gucci. I come to rely on it a few times; it's simple and efficient!

I have another project, where I wanted to include gucci because I liked how you included sprig, etc. and the API seems sane. Therefor, I extracted some functions to be able to use gucci as a library.

This is an example:

// i have a replace in go.mod
import (
  github.com/noqcks/gucci/gucci
)

tmpl, _ := gucci.LoadTemplateFile(fileTemplate)
writer, _ := os.Create(fileRendered)
err := gucci.ExecuteTemplate(gucci.Env(), writer, tmpl)
if err {
// etc.
}

I can also merge/override variables, etc.. But this is to show you what I want to achieve.

TL;DR it seems to work, do you have any thoughts on including this?

Thanks, Till

noqcks commented 4 years ago

Hey!

I would like to keep it as only CLI application unless there are requests from others for this ability.

Thanks for using the tool!