// tmpl executes the given template text on data, writing the result to w.
555841
func tmpl(w io.Writer, text string, data interface{}) error {
	t := template.New("top")
	t.Funcs(templateFuncs)
	template.Must(t.Parse(text))
	return t.Execute(w, data)
}
1228274
func (cnf *Mycnf) fillMycnfTemplate(tmplSrc string) (string, error) {
	myTemplate, err := template.New("").Parse(tmplSrc)
	if err != nil {
		return "", err
	}
	mycnfData := new(bytes.Buffer)
	err = myTemplate.Execute(mycnfData, cnf)
	if err != nil {
		return "", err
	}
	return mycnfData.String(), nil
}
462089
func TmplToString(tmpl string, data interface{}) string {
	t := template.New("tmpl").Funcs(BeeFuncMap())
	template.Must(t.Parse(tmpl))

	var doc bytes.Buffer
	err := t.Execute(&doc, data)
	MustCheck(err)

	return doc.String()
}
663375
func NewTemplate(context *context.Context) *Template {
	tpl := new(Template)
	tpl.Context = context
	return tpl
}
1000
func (h *TextHandler) SetTextTemplate(t *template.Template) {
	h.mtx.Lock()
	defer h.mtx.Unlock()
	h.template = t
}
1366190
func (c *Client) SearchIndexTemplate(index, tmpl string, data interface{}, v interface{}) error {
	var buf bytes.Buffer

	t, err := template.New("main").Parse(tmpl)
	if err != nil {
		return err
	}

	if err := t.Execute(&buf, data); err != nil {
		return err
	}

	return c.SearchIndexString(index, buf.String(), v)
}
412307
func (tpl *Template) Execute(context Context) (string, error) {
	// Execute template
	buffer, err := tpl.newBufferAndExecute(context)
	if err != nil {
		return "", err
	}

	return buffer.String(), nil

}
682627
func Execute(tplName string, w io.Writer, data interface{}) error {
	mu.RLock()
	t, ok := templaters[tplName]
	mu.RUnlock()
	if !ok {
		return ErrTemplateNotExist
	}
	return t.Execute(w, data)
}
898277
func NewTemplate() *Template {
	return &Template{
		AWSTemplateFormatVersion: "2010-09-09",
		Description:              "",
		Metadata:                 map[string]interface{}{},
		Parameters:               map[string]interface{}{},
		Mappings:                 map[string]interface{}{},
		Conditions:               map[string]interface{}{},
		Resources:                Resources{},
		Outputs:                  map[string]interface{}{},
	}
}
660340
func (s *Application) NewTemplateEngine(tmplPath string, conf *render.Config) driver.Driver {
	if len(tmplPath) == 0 {
		tmplPath = s.ThemeDir()
	}
	eng := render.New(conf.Engine, tmplPath, s.Core.Logger())
	eng.Init()
	eng.SetDebug(conf.Debug)
	return eng
}
441428
func (s *TemplateService) RegisterTemplate(p *RegisterTemplateParams) (*RegisterTemplateResponse, error) {
	resp, err := s.cs.newRequest("registerTemplate", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r RegisterTemplateResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
1282845
func main() {
	var (
		extractLiteralTemplate = createTemplate("templates/extract/literal.go.tmpl")
		extractMapTemplate     = createTemplate("templates/extract/map_string_string.go.tmpl")
	)

	for _, opt := range options {
		filename := generateFilename(opt.Name)
		filepath := "../opt/" + filename

		if shouldBeGenerated(filepath) {
			switch opt.DefaultValue.(type) {
			case nil, bool, int, string, []string, map[string][]string:
				generateFile(extractLiteralTemplate, opt.Name, filepath)
			case map[string]string:
				generateFile(extractMapTemplate, opt.Name, filepath)
			default:
				fmt.Printf("cannot generate extract option file for %s: unhandled type %#v", opt.Name, opt.DefaultValue)
				os.Exit(1)
			}
		}
	}
}
472092
func (m *Message) Render(tmpl *template.Template) ([]byte, error) {
	buf := new(bytes.Buffer)
	err := tmpl.Execute(buf, m)
	if err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
304447
func (g *gomplate) runTemplate(t *tplate) error {
	tmpl, err := t.toGoTemplate(g)
	if err != nil {
		return err
	}

	switch t.target.(type) {
	case io.Closer:
		if t.target != os.Stdout {
			// nolint: errcheck
			defer t.target.(io.Closer).Close()
		}
	}
	err = tmpl.Execute(t.target, g.context)
	return err
}
151444
func (t *Template) Execute(w io.Writer, variables VarMap, data interface{}) error {
	return t.ExecuteI18N(nil, w, variables, data)
}
1056178
func WriteData(pkg string, outFilePath string, tmpl *template.Template, data interface{}) (retErr error) {
	buffer := bytes.NewBuffer(nil)
	metadata := getMetadata(pkg, data)
	if err := tmpl.Execute(buffer, metadata); err != nil {
		return err
	}
	formatted, err := format.Source(buffer.Bytes())
	if err != nil {
		return err
	}
	file, err := os.Create(outFilePath)
	if err != nil {
		return err
	}
	defer func() {
		if err := file.Close(); err != nil && retErr == nil {
			retErr = err
		}
	}()
	if _, err := io.Copy(file, bytes.NewReader(formatted)); err != nil {
		return err
	}
	return nil
}
1124771
func (t *TemplateAdapter) ExecuteToString(data interface{}) (string, error) {
	b := bp.GetBuffer()
	defer bp.PutBuffer(b)
	if err := t.Execute(b, data); err != nil {
		return "", err
	}
	return b.String(), nil
}