github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/genny/actions/build_templates.go (about)

     1  package actions
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/gobuffalo/genny/v2"
     7  )
     8  
     9  func buildTemplates(pres *presenter) genny.RunFn {
    10  	return func(r *genny.Runner) error {
    11  		f, err := box.FindString("view.plush.html.tmpl")
    12  		if err != nil {
    13  			return err
    14  		}
    15  		for _, a := range pres.Actions {
    16  			pres.Data["action"] = a
    17  			fn := fmt.Sprintf("templates/%s/%s.plush.html.tmpl", pres.Name.Folder(), a.File())
    18  			xf := genny.NewFileS(fn, f)
    19  			xf, err = transform(pres, xf)
    20  			if err != nil {
    21  				return err
    22  			}
    23  			if err := r.File(xf); err != nil {
    24  				return err
    25  			}
    26  		}
    27  		return nil
    28  	}
    29  }