// CreateTemplate will save the provided template struct as a new template
// and return the ID of the new template.
347971
func (client *Client) CreateTemplate(ctx context.Context, template Template) (string, error) {
	content := map[string]interface{}{
		"name":     template.Name,
		"template": template.Content,
	}

	if err := client.request(ctx, "POST", "templates", content, &template); err != nil {
		return "", err
	}

	return template.ID, nil
}
735059
func (p *Plugin) NewProcessFromTemplate(tmp *process.Template) ProcessInstance {
	newTmpPr, err := p.templateToProcess(tmp)
	if err != nil {
		p.Log.Errorf("cannot create a process from template: %v", err)
		return nil
	}
	p.processes = append(p.processes, newTmpPr)

	go newTmpPr.watch()

	return newTmpPr
}
808976
func (_m *FacadeInterface) DeployTemplate(ctx datastore.Context, poolID string, templateID string, deploymentID string) ([]string, error) {
	ret := _m.Called(ctx, poolID, templateID, deploymentID)

	var r0 []string
	if rf, ok := ret.Get(0).(func(datastore.Context, string, string, string) []string); ok {
		r0 = rf(ctx, poolID, templateID, deploymentID)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]string)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(datastore.Context, string, string, string) error); ok {
		r1 = rf(ctx, poolID, templateID, deploymentID)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
944504
func (c CloudstackClient) DeleteTemplate(id string) (DeleteTemplateResponse, error) {
	var resp DeleteTemplateResponse
	params := url.Values{}
	params.Set("id", id)
	response, err := NewRequest(c, "deleteTemplate", params)
	if err != nil {
		return resp, err
	}

	resp = response.(DeleteTemplateResponse)
	return resp, err
}
453561
func (g *Generator) AddTemplateFunc(name string, f interface{}) {
	g.templateFuncs[name] = f
}
824670
func New(options ...Option) *Template {
	t := &Template{
		elems:      make([]node, 0),
		partials:   make(map[string]*Template),
		startDelim: "{{",
		endDelim:   "}}",
		silentMiss: true,
	}
	t.Option(options...)
	return t
}
171065
func (o *Me) CreateGatewayTemplate(child *GatewayTemplate) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
1157429
func NewFromTemplate(r io.Reader) (Generator, error) {
	var config rspec.Spec
	if err := json.NewDecoder(r).Decode(&config); err != nil {
		return Generator{}, err
	}

	envCache := map[string]int{}
	if config.Process != nil {
		envCache = createEnvCacheMap(config.Process.Env)
	}

	return Generator{
		Config: &config,
		envMap: envCache,
	}, nil
}
1202396
func (s *TemplateService) PrepareTemplate(p *PrepareTemplateParams) (*PrepareTemplateResponse, error) {
	resp, err := s.cs.newRequest("prepareTemplate", p.toURLValues())
	if err != nil {
		return nil, err
	}

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

	return &r, nil
}
1085192
func Template(runOnStartup bool) POption {
	return func(p *POptions) {
		p.template = true
		p.runOnStartup = runOnStartup
	}
}
1272377
func CreatePodTemplate(template v1.PodTemplateSpec, generation *int64, hash string) v1.PodTemplateSpec {
	newTemplate := *template.DeepCopy()

	AddOrUpdateDaemonPodTolerations(&newTemplate.Spec)

	if newTemplate.ObjectMeta.Labels == nil {
		newTemplate.ObjectMeta.Labels = make(map[string]string)
	}
	if generation != nil {
		newTemplate.ObjectMeta.Labels[extensions.DaemonSetTemplateGenerationKey] = fmt.Sprint(*generation)
	}
	// TODO: do we need to validate if the DaemonSet is RollingUpdate or not?
	if len(hash) > 0 {
		newTemplate.ObjectMeta.Labels[extensions.DefaultDaemonSetUniqueLabelKey] = hash
	}
	return newTemplate
}
243789
func (loader *TemplateLoader) CreateTemplateEngine(templateEngineName string) (TemplateEngine, error) {
	if "" == templateEngineName {
		templateEngineName = GO_TEMPLATE
	}
	factory := templateLoaderMap[templateEngineName]
	if nil == factory {
		fmt.Printf("registered factories %#v\n %s \n", templateLoaderMap, templateEngineName)
		return nil, errors.New("Unknown template engine name - " + templateEngineName + ".")
	}
	templateEngine, err := factory(loader)
	if nil != err {
		return nil, errors.New("Failed to init template engine (" + templateEngineName + "), " + err.Error())
	}

	templateLog.Debug("CreateTemplateEngine: init templates", "name", templateEngineName)
	return templateEngine, nil
}
205412
func (b *Bar) Template(s string) {
	t, err := template.New("").Parse(s)
	if err != nil {
		panic(err)
	}

	b.tmpl = t
}
158769
func (c *FakeTemplateInstances) Create(templateInstance *template.TemplateInstance) (result *template.TemplateInstance, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewCreateAction(templateinstancesResource, c.ns, templateInstance), &template.TemplateInstance{})

	if obj == nil {
		return nil, err
	}
	return obj.(*template.TemplateInstance), err
}
1297993
func (s *UpdateTemplateInput) SetTemplate(v *Template) *UpdateTemplateInput {
	s.Template = v
	return s
}
852217
func NewTemplate(input string) (*Template, error) {
	hm, err := NewHelperMap()
	if err != nil {
		return nil, errors.WithStack(err)
	}
	t := &Template{
		Input:   input,
		Helpers: hm,
	}
	err = t.Parse()
	if err != nil {
		return t, errors.WithStack(err)
	}
	return t, nil
}
858962
func (c *Client) CopyTemplate(p *CopyTemplateParameter) (*Template, error) {
	obj, err := c.Request("copyTemplate", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Template), err
}