// ExecuteTemplate renders a "tmpl" partial template to the `context#ResponseWriter`.
322654
func ExecuteTemplate(ctx iris.Context, tmpl templates.Partial) {
	ctx.Gzip(true)
	ctx.ContentType("text/html")
	templates.WriteTemplate(ctx.ResponseWriter(), tmpl)
}
76095
func (t *Template) Execute(mapping func(string) string) (str string, err error) {
	b := new(bytes.Buffer)
	s := new(state)
	s.node = t.tree.Root
	s.mapper = mapping
	s.writer = b
	err = t.eval(s)
	if err != nil {
		return
	}
	return b.String(), nil
}
162460
func (s *TemplateService) UpgradeRouterTemplate(p *UpgradeRouterTemplateParams) (*UpgradeRouterTemplateResponse, error) {
	resp, err := s.cs.newRequest("upgradeRouterTemplate", p.toURLValues())
	if err != nil {
		return nil, err
	}

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

	return &r, nil
}
246243
func expandTemplate(tmpl string) (pkg string, err error) {
	pkg, err = template.DefaultExpander().Expand(tmpl)
	if err != nil {
		err = commandLineError{err}
	}
	return
}
841929
func (s *TemplateService) UpdateTemplate(p *UpdateTemplateParams) (*UpdateTemplateResponse, error) {
	resp, err := s.cs.newRequest("updateTemplate", p.toURLValues())
	if err != nil {
		return nil, err
	}

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

	return &r, nil
}
433294
func ValidateTemplate(template *templateapi.Template) (allErrs field.ErrorList) {
	allErrs = validation.ValidateObjectMeta(&template.ObjectMeta, true, ValidateTemplateName, field.NewPath("metadata"))
	allErrs = append(allErrs, validateTemplateBody(template)...)
	return
}
731379
func (loader *FileSystemLoader) LoadTemplate(name string) (string, error) {
	f, err := os.Open(path.Join(loader.BaseDir, name))
	if err != nil {
		return "", err
	}
	b, err := ioutil.ReadAll(f)
	return string(b), err
}
537026
func ExecuteTemplate(tmpl ExecutableTemplate, data interface{}) string {
	var b bytes.Buffer
	if err := tmpl.Execute(&b, data); err != nil {
		utilLog.Error("ExecuteTemplate: Execute failed", "error", err)
	}
	return b.String()
}
376147
func (p *Plugin) processToTemplate(pr *Process) (*process.Template, error) {
	if pr.name == "" {
		return nil, errors.Errorf("cannot create template from process, missing name")
	}
	if pr.cmd == "" {
		return nil, errors.Errorf("cannot create template from process, missing command")
	}

	pOptions := &process.TemplatePOptions{
		Args:    pr.options.args,
		Restart: pr.options.restart,
		OutWriter: func(w io.Writer) bool {
			return w != nil
		}(pr.options.outWriter),
		ErrWriter: func(w io.Writer) bool {
			return w != nil
		}(pr.options.errWriter),
		Detach:       pr.options.detach,
		RunOnStartup: pr.options.runOnStartup,
		Notify: func(notifyChan chan status.ProcessStatus) bool {
			if notifyChan == nil {
				return false
			}
			return true
		}(pr.options.notifyChan),
		AutoTerminate: pr.options.autoTerm,
	}

	return &process.Template{
		Name:     pr.name,
		Cmd:      pr.cmd,
		POptions: pOptions,
	}, nil
}
200597
func ServeTemplate(w http.ResponseWriter, name string, data map[string]interface{}) {
	// cast the writer to the resposneWriter, get the router
	r := w.(*responseWriter).Router

	r.RLock()
	defer r.RUnlock()

	if data == nil {
		data = map[string]interface{}{}
	}

	// append global params to the template
	for k, v := range r.params {
		data[k] = v
	}

	var buf bytes.Buffer
	if err := r.views.ExecuteTemplate(&buf, name, data); err != nil {
		panic(err)
		return
	}

	// set the content length, type, etc
	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	w.Write(buf.Bytes())
}
912028
func (s *AmberEngine) ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error {
	// re-parse the templates if reload is enabled.
	if s.reload {
		// locks to fix #872, it's the simplest solution and the most correct,
		// to execute writers with "wait list", one at a time.
		s.rmu.Lock()
		defer s.rmu.Unlock()
		if err := s.Load(); err != nil {
			return err
		}
	}

	if tmpl := s.fromCache(filename); tmpl != nil {
		return tmpl.Execute(w, bindingData)
	}

	return fmt.Errorf("Template with name %s doesn't exists in the dir", filename)
}
1110056
func (s *Store) GetTemplate(context.Context, string) ([]byte, error) {
	return nil, fmt.Errorf("not supported")
}
1019841
func (f *SourceFile) ExecuteTemplate(name, source string, funcMap template.FuncMap, data interface{}) error {
	tmpl, err := template.New(name).Funcs(DefaultFuncMap).Funcs(funcMap).Parse(source)
	if err != nil {
		panic(err) // bug
	}
	return tmpl.Execute(f, data)
}
694152
func (mt *MessageTemplate) Execute(pluralForm plural.Form, data interface{}, funcs template.FuncMap) (string, error) {
	t := mt.PluralTemplates[pluralForm]
	if t == nil {
		return "", pluralFormNotFoundError{
			pluralForm: pluralForm,
			messageID:  mt.Message.ID,
		}
	}
	if err := t.parse(mt.LeftDelim, mt.RightDelim, funcs); err != nil {
		return "", err
	}
	if t.Template == nil {
		return t.Src, nil
	}
	var buf bytes.Buffer
	if err := t.Template.Execute(&buf, data); err != nil {
		return "", err
	}
	return buf.String(), nil
}
1076967
func newTemplate(source string) *Template {
	return &Template{
		source:   source,
		helpers:  make(map[string]reflect.Value),
		partials: make(map[string]*partial),
	}
}
1247341
func (tpl *Template) ExecuteWriter(context Context, writer io.Writer) error {
	buf, err := tpl.newBufferAndExecute(context)
	if err != nil {
		return err
	}
	_, err = buf.WriteTo(writer)
	if err != nil {
		return err
	}
	return nil
}
70669
func (w *ResourcesWriter) Execute(data *ResourceData) error {
	return w.ExecuteTemplate("resource", resourceT, nil, data)
}