// Template formatter for "html" format.
481187
func htmlFmt(w io.Writer, format string, x ...interface{}) string {
	writeAny(w, true, x[0])
	return ""
}
1291161
func (s *GenerateTemplateInput) SetTemplateFormat(v string) *GenerateTemplateInput {
	s.TemplateFormat = &v
	return s
}
1306182
func (r *rawTemplate) Template() (*Template, error) {
	var result Template
	var errs error

	// Copy some literals
	result.Description = r.Description
	result.MinVersion = r.MinVersion
	result.RawContents = r.RawContents

	// Gather the comments
	if len(r.Comments) > 0 {
		result.Comments = make(map[string]string, len(r.Comments))

		for _, c := range r.Comments {
			for k, v := range c {
				result.Comments[k] = v
			}
		}
	}

	// Gather the variables
	if len(r.Variables) > 0 {
		result.Variables = make(map[string]*Variable, len(r.Variables))
	}

	for k, rawV := range r.Variables {
		var v Variable
		v.Key = k

		// Variable is required if the value is exactly nil
		v.Required = rawV == nil

		// Weak decode the default if we have one
		if err := r.decoder(&v.Default, nil).Decode(rawV); err != nil {
			errs = multierror.Append(errs, fmt.Errorf(
				"variable %s: %s", k, err))
			continue
		}

		for _, sVar := range r.SensitiveVariables {
			if sVar == k {
				result.SensitiveVariables = append(result.SensitiveVariables, &v)
			}
		}

		result.Variables[k] = &v
	}

	// Let's start by gathering all the builders
	if len(r.Builders) > 0 {
		result.Builders = make(map[string]*Builder, len(r.Builders))
	}
	for i, rawB := range r.Builders {
		var b Builder
		if err := mapstructure.WeakDecode(rawB, &b); err != nil {
			errs = multierror.Append(errs, fmt.Errorf(
				"builder %d: %s", i+1, err))
			continue
		}

		// Set the raw configuration and delete any special keys
		b.Config = rawB.(map[string]interface{})

		delete(b.Config, "name")
		delete(b.Config, "type")

		if len(b.Config) == 0 {
			b.Config = nil
		}

		// If there is no type set, it is an error
		if b.Type == "" {
			errs = multierror.Append(errs, fmt.Errorf(
				"builder %d: missing 'type'", i+1))
			continue
		}

		// The name defaults to the type if it isn't set
		if b.Name == "" {
			b.Name = b.Type
		}

		// If this builder already exists, it is an error
		if _, ok := result.Builders[b.Name]; ok {
			errs = multierror.Append(errs, fmt.Errorf(
				"builder %d: builder with name '%s' already exists",
				i+1, b.Name))
			continue
		}

		// Append the builders
		result.Builders[b.Name] = &b
	}

	// Gather all the post-processors
	if len(r.PostProcessors) > 0 {
		result.PostProcessors = make([][]*PostProcessor, 0, len(r.PostProcessors))
	}
	for i, v := range r.PostProcessors {
		// Parse the configurations. We need to do this because post-processors
		// can take three different formats.
		configs, err := r.parsePostProcessor(i, v)
		if err != nil {
			errs = multierror.Append(errs, err)
			continue
		}

		// Parse the PostProcessors out of the configs
		pps := make([]*PostProcessor, 0, len(configs))
		for j, c := range configs {
			var pp PostProcessor
			if err := r.decoder(&pp, nil).Decode(c); err != nil {
				errs = multierror.Append(errs, fmt.Errorf(
					"post-processor %d.%d: %s", i+1, j+1, err))
				continue
			}

			// Type is required
			if pp.Type == "" {
				errs = multierror.Append(errs, fmt.Errorf(
					"post-processor %d.%d: type is required", i+1, j+1))
				continue
			}

			// Set the raw configuration and delete any special keys
			pp.Config = c

			// The name defaults to the type if it isn't set
			if pp.Name == "" {
				pp.Name = pp.Type
			}

			delete(pp.Config, "except")
			delete(pp.Config, "only")
			delete(pp.Config, "keep_input_artifact")
			delete(pp.Config, "type")
			delete(pp.Config, "name")

			if len(pp.Config) == 0 {
				pp.Config = nil
			}

			pps = append(pps, &pp)
		}

		result.PostProcessors = append(result.PostProcessors, pps)
	}

	// Gather all the provisioners
	if len(r.Provisioners) > 0 {
		result.Provisioners = make([]*Provisioner, 0, len(r.Provisioners))
	}
	for i, v := range r.Provisioners {
		var p Provisioner
		if err := r.decoder(&p, nil).Decode(v); err != nil {
			errs = multierror.Append(errs, fmt.Errorf(
				"provisioner %d: %s", i+1, err))
			continue
		}

		// Type is required before any richer validation
		if p.Type == "" {
			errs = multierror.Append(errs, fmt.Errorf(
				"provisioner %d: missing 'type'", i+1))
			continue
		}

		// Set the raw configuration and delete any special keys
		p.Config = v.(map[string]interface{})

		delete(p.Config, "except")
		delete(p.Config, "only")
		delete(p.Config, "override")
		delete(p.Config, "pause_before")
		delete(p.Config, "type")
		delete(p.Config, "timeout")

		if len(p.Config) == 0 {
			p.Config = nil
		}

		result.Provisioners = append(result.Provisioners, &p)
	}

	// Push
	if len(r.Push) > 0 {
		var p Push
		if err := r.decoder(&p, nil).Decode(r.Push); err != nil {
			errs = multierror.Append(errs, fmt.Errorf(
				"push: %s", err))
		}

		result.Push = p
	}

	// If we have errors, return those with a nil result
	if errs != nil {
		return nil, errs
	}

	return &result, nil
}
1344590
func (g *Generator) ProcessTemplate(tmplName, tmpl string, data interface{}) error {
	vars := []string{}
	for varName, varValue := range g.vars {
		vars = append(vars, fmt.Sprintf("{{ $%s := %q }}", varName, varValue))
	}

	if len(vars) > 0 {
		tmpl = strings.Join(vars, "\n") + "\n" + tmpl
	}

	t, err := template.New(tmplName).Funcs(g.templateFuncs).Parse(tmpl)
	if err != nil {
		return fmt.Errorf("failed to parse template: %v\n%s", err, tmpl)
	}

	if err := t.Execute(g.body, data); err != nil {
		return fmt.Errorf("failed to execute template: %v", err)
	}

	return nil
}
469795
func (ctx *MyContext) HTML(htmlContents string) (int, error) {
	ctx.Application().Logger().Infof("Executing .HTML function from MyContext")

	ctx.ContentType("text/html")
	return ctx.WriteString(htmlContents)
}
1342383
func (t *TemplateRenderable) RenderHTML(_ ...string) template.HTML {
	return template.HTML(t.Render())
}
1011795
func (f *Fpdf) UseTemplate(t Template) {
	if t == nil {
		f.SetErrorf("template is nil")
		return
	}
	corner, size := t.Size()
	f.UseTemplateScaled(t, corner, size)
}
359497
func (r *RenderRenderer) Render(w http.ResponseWriter, code int, templateName string, data interface{}, layout string) {
	if layout != "" {
		r.r.HTML(w, code, templateName, data, render.HTMLOptions{Layout: layout})
		return
	}
	r.r.HTML(w, code, templateName, data)
}
434648
func (p *partial) template() (*Template, error) {
	if p.tpl == nil {
		var err error

		p.tpl, err = Parse(p.source)
		if err != nil {
			return nil, err
		}
	}

	return p.tpl, nil
}
58498
func (ctx *context) HTML(htmlContents string) (int, error) {
	ctx.ContentType(ContentHTMLHeaderValue)
	return ctx.writer.WriteString(htmlContents)
}
32995
func (ns *Namespace) HTMLAttr(a interface{}) (template.HTMLAttr, error) {
	s, err := cast.ToStringE(a)
	return template.HTMLAttr(s), err
}
101124
func Convert_v1_Template_To_template_Template(in *v1.Template, out *template.Template, s conversion.Scope) error {
	return autoConvert_v1_Template_To_template_Template(in, out, s)
}
226831
func (set *TemplateSet) RenderTemplateString(s string, ctx Context) (string, error) {
	set.firstTemplateCreated = true

	tpl := Must(set.FromString(s))
	result, err := tpl.Execute(ctx)
	if err != nil {
		return "", err
	}
	return result, nil
}
23614
func RenderTemplate(destPath, srcPath string, data interface{}) (err error) {
	tmpl, err := template.ParseFiles(srcPath)
	if err != nil {
		return NewBuildIfError(err, "Failed to parse template "+srcPath)
	}

	f, err := os.Create(destPath)
	if err != nil {
		return NewBuildIfError(err, "Failed to create  ", "path", destPath)
	}

	err = tmpl.Execute(f, data)
	if err != nil {
		return NewBuildIfError(err, "Failed to Render template "+srcPath)
	}

	err = f.Close()
	if err != nil {
		return NewBuildIfError(err, "Failed to close file stream "+destPath)
	}
	return
}
1140150
func ProcessTemplate(t T, templateContent string, value interface{}) string {
	tmp, err := template.New("temporary").Parse(templateContent)
	if err != nil {
		logfatal(t, sfatalf("failed to parse:%v", err))
		return ""
	}
	var buf bytes.Buffer
	err = tmp.Execute(&buf, value)
	if err != nil {
		logfatal(t, sfatalf("failed to execute template:%v", err))
		return ""
	}
	return buf.String()
}
195772
func NewTemplateRenderable(content string) (*TemplateRenderable, error) {
	tl, err := template.New("").Parse(content)
	if err != nil {
		return nil, err
	}

	tr := TemplateRenderable{
		tmpl:  tl,
		cache: bytes.NewBuffer([]byte{}),
	}

	return &tr, nil
}
770537
func Template() (c *TemplateController) {
	return &TemplateController{
		List:   templateList,
		New:    templateNew,
		Create: templateCreate,
		Edit:   templateEdit,
		Update: templateUpdate,
		Delete: templateDelete,
	}
}