// template returns parsed partial template
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
}
378808
func (c *Controller) RenderTemplate(templatePath string) Result {
	c.setStatusIfNil(http.StatusOK)

	// Get the Template.
	lang, _ := c.ViewArgs[CurrentLocaleViewArg].(string)
	template, err := MainTemplateLoader.TemplateLang(templatePath, lang)
	if err != nil {
		return c.RenderError(err)
	}

	return &RenderTemplateResult{
		Template: template,
		ViewArgs: c.ViewArgs,
	}
}
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()
}
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
}
899027
func (engine *Engine) SetHTMLTemplate(templ *template.Template) {
	if len(engine.trees) > 0 {
		debugPrintWARNINGSetHTMLTemplate()
	}

	engine.HTMLRender = render.HTMLProduction{Template: templ.Funcs(engine.FuncMap)}
}
1085192
func Template(runOnStartup bool) POption {
	return func(p *POptions) {
		p.template = true
		p.runOnStartup = runOnStartup
	}
}
1051936
func NewTemplate(g *libkb.GlobalContext) *Template {
	return &Template{
		Contextified: libkb.NewContextified(g),
	}
}
1052172
func Template(appName, commonName string) (*x509.Certificate, error) {
	// generate a random serial number (a real cert authority would have some logic behind this)
	serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
	serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
	if err != nil {
		return nil, errors.New("failed to generate serial number: " + err.Error())
	}

	tmpl := x509.Certificate{
		IsCA:         true,
		SerialNumber: serialNumber,
		Subject: pkix.Name{
			Organization: []string{appName},
			CommonName:   commonName,
		},

		SignatureAlgorithm:    x509.SHA256WithRSA,
		NotBefore:             time.Now(),
		NotAfter:              time.Now().Add(time.Hour * 24 * 365 * 4), // valid for 4 years
		BasicConstraintsValid: true,
	}

	return &tmpl, nil
}
154719
func (c *Context) HTML(status int, name string) {
	log.Trace("Template: %s", name)
	c.Context.HTML(status, name)
}
322654
func ExecuteTemplate(ctx iris.Context, tmpl templates.Partial) {
	ctx.Gzip(true)
	ctx.ContentType("text/html")
	templates.WriteTemplate(ctx.ResponseWriter(), tmpl)
}
924742
func (t *Templater) Template(path string) (tpl *template.Template, ok bool) {
	t.m.Lock()
	defer t.m.Unlock()
	tpl, ok = t.templates[path]
	return
}
445500
func DeserializeTemplate(b []byte) (Template, error) {
	tpl := new(FpdfTpl)
	dec := gob.NewDecoder(bytes.NewBuffer(b))
	err := dec.Decode(tpl)
	return tpl, err
}
475473
func Compile(path, base string) error {
	mu.Lock()
	defer mu.Unlock()

	return compileTemplate(path, base)
}
248732
func (s *SendTemplatedEmailInput) SetTemplate(v string) *SendTemplatedEmailInput {
	s.Template = &v
	return s
}
205412
func (b *Bar) Template(s string) {
	t, err := template.New("").Parse(s)
	if err != nil {
		panic(err)
	}

	b.tmpl = t
}
425485
func (t *templateHandler) AddTemplate(name, tpl string) error {
	h := t.getTemplateHandler(name)
	_, err := h.addTemplate(name, tpl)
	if err != nil {
		return err
	}
	return nil
}
450591
func (c *Client) CreateTemplate(p *CreateTemplateParameter) (*Template, error) {
	obj, err := c.Request("createTemplate", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Template), err
}