// Create a new template which can be used to attach template versions to
189978
func (mg *MailgunImpl) CreateTemplate(ctx context.Context, template *Template) error {
	r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint))
	r.setClient(mg.Client())
	r.setBasicAuth(basicAuthUser, mg.APIKey())

	payload := newUrlEncodedPayload()

	if template.Name != "" {
		payload.addValue("name", template.Name)
	}
	if template.Description != "" {
		payload.addValue("description", template.Description)
	}

	if template.Version.Engine != "" {
		payload.addValue("engine", string(template.Version.Engine))
	}
	if template.Version.Template != "" {
		payload.addValue("template", template.Version.Template)
	}
	if template.Version.Comment != "" {
		payload.addValue("comment", template.Version.Comment)
	}

	var resp templateResp
	if err := postResponseFromJSON(ctx, r, payload, &resp); err != nil {
		return err
	}
	*template = resp.Item
	return nil
}
117213
func (t *Template) New(name string) *Template {
	t.init()
	return &Template{
		name:       name,
		common:     t.common,
		leftDelim:  t.leftDelim,
		rightDelim: t.rightDelim,
	}
}
163035
func (c *Clientset) Template() templateinternalversion.TemplateInterface {
	return &faketemplateinternalversion.FakeTemplate{Fake: &c.Fake}
}
318912
func (c *podTemplates) Create(podTemplate *api.PodTemplate) (result *api.PodTemplate, err error) {
	result = &api.PodTemplate{}
	err = c.client.Post().
		Namespace(c.ns).
		Resource("podtemplates").
		Body(podTemplate).
		Do().
		Into(result)
	return
}
605897
func compileTemplate(p, base string) error {
	ext := path.Ext(p)
	c, ok := compilers[ext]
	// Ignore file if no template compiler exist for this extension
	if ok {
		t, err := c.Compile(p)
		if err != nil {
			return err
		}
		key, err := filepath.Rel(base, p)
		if err != nil {
			return err
		}
		ghost.LogFn("ghost.templates : storing template for file %s", key)
		templaters[key] = t
	}
	return nil
}
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
}
312660
func New(name string, fn AssetFunc) *Template {
	return &Template{fn, template.New(name)}
}
252567
func (r *Router) Template(t *template.Template) {
	r.Lock()
	defer r.Unlock()
	r.views = template.Must(t.Clone())
}
1205060
func (f *Fpdf) CreateTemplate(fn func(*Tpl)) Template {
	return newTpl(PointType{0, 0}, f.curPageSize, f.defOrientation, f.unitStr, f.fontDirStr, fn, f)
}
581543
func AddSourceTemplates(t *template.Template) {
	template.Must(t.Parse(`{{define "weblistcss"}}` + weblistPageCSS + `{{end}}`))
	template.Must(t.Parse(`{{define "weblistjs"}}` + weblistPageScript + `{{end}}`))
}
1289053
func newPodTemplates(c *CoreV1Client, namespace string) *podTemplates {
	return &podTemplates{
		client: c.RESTClient(),
		ns:     namespace,
	}
}
1033563
func (t *TemplateResource) createStageFile() error {
	log.Debug("Using source template " + t.Src)

	if !util.IsFileExist(t.Src) {
		return errors.New("Missing template: " + t.Src)
	}

	log.Debug("Compiling source template " + t.Src)

	tmpl, err := template.New(filepath.Base(t.Src)).Funcs(t.funcMap).ParseFiles(t.Src)
	if err != nil {
		return fmt.Errorf("Unable to process template %s, %s", t.Src, err)
	}

	// create TempFile in Dest directory to avoid cross-filesystem issues
	temp, err := ioutil.TempFile(filepath.Dir(t.Dest), "."+filepath.Base(t.Dest))
	if err != nil {
		return err
	}

	if err = tmpl.Execute(temp, nil); err != nil {
		temp.Close()
		os.Remove(temp.Name())
		return err
	}
	defer temp.Close()

	// Set the owner, group, and mode on the stage file now to make it easier to
	// compare against the destination configuration file later.
	os.Chmod(temp.Name(), t.FileMode)
	os.Chown(temp.Name(), t.Uid, t.Gid)
	t.StageFile = temp
	return nil
}
1267659
func Convert_v1_TemplateInstance_To_template_TemplateInstance(in *v1.TemplateInstance, out *template.TemplateInstance, s conversion.Scope) error {
	return autoConvert_v1_TemplateInstance_To_template_TemplateInstance(in, out, s)
}
749741
func Convert_template_Template_To_v1_Template(in *template.Template, out *v1.Template, s conversion.Scope) error {
	return autoConvert_template_Template_To_v1_Template(in, out, s)
}
622956
func New(name string) *htmlTemplate.Template {
	return htmlTemplate.New(name).Funcs(GtfFuncMap)
}
164076
func (r *GormRepository) Create(ctx context.Context, s SpaceTemplate) (*SpaceTemplate, error) {
	if uuid.Equal(s.ID, uuid.Nil) {
		s.ID = uuid.NewV4()
	}

	if err := s.Validate(); err != nil {
		log.Error(ctx, map[string]interface{}{"space_template": s, "err": err}, "space template is invalid")
		return nil, errs.Wrap(err, "space template is invalid")
	}

	// Create space template
	db := r.db.Create(&s)
	if err := db.Error; err != nil {
		log.Error(ctx, map[string]interface{}{"space_template": s, "err": err}, "failed to create space template")
		// name needs to be unique
		if gormsupport.IsUniqueViolation(err, "space_templates_name_uidx") {
			return nil, errors.NewBadParameterError("name", s.Name).Expected("unique")
		}
		return nil, errs.Wrap(err, "failed to create space template")
	}
	log.Debug(ctx, map[string]interface{}{"space_template_id": s.ID}, "space template created successfully")
	return &s, nil
}
1083363
func buildURLTemplate(path string) string {
	template, start, end := "", -1, -1
	for i := 0; i < len(path); i++ {
		if path[i] == '<' && start < 0 {
			start = i
		} else if path[i] == '>' && start >= 0 {
			name := path[start+1 : i]
			for j := start + 1; j < i; j++ {
				if path[j] == ':' {
					name = path[start+1 : j]
					break
				}
			}
			template += path[end+1:start] + "<" + name + ">"
			end = i
			start = -1
		}
	}
	if end < 0 {
		template = path
	} else if end < len(path)-1 {
		template += path[end+1:]
	}
	return template
}