// YieldTemplate yields a template same as include
424945
func (st *Runtime) YieldTemplate(name string, context interface{}) {

	t, err := st.set.GetTemplate(name)
	if err != nil {
		panic(fmt.Errorf("include: template %q was not found", name))
	}

	st.newScope()
	st.blocks = t.processedBlocks

	Root := t.Root
	if t.extends != nil {
		Root = t.extends.Root
	}

	if context != nil {
		c := st.context
		st.context = reflect.ValueOf(context)
		st.executeList(Root)
		st.context = c
	} else {
		st.executeList(Root)
	}

	st.releaseScope()
}
380170
func generateResource(parent, name string, resource *raml.Resource, t *template.Template, f *os.File) string {
	path := parent + name

	for _, method := range resource.Methods() {
		err := t.Execute(f, HandlerInfo{ramlapi.Variableize(method.DisplayName), method.Name, path, method.Description})
		if err != nil {
			log.Println("executing template:", err)
		}
	}

	// Get all children.
	for nestname, nested := range resource.Nested {
		return generateResource(path, nestname, nested, t, f)
	}
	return path
}
441428
func (s *TemplateService) RegisterTemplate(p *RegisterTemplateParams) (*RegisterTemplateResponse, error) {
	resp, err := s.cs.newRequest("registerTemplate", p.toURLValues())
	if err != nil {
		return nil, err
	}

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

	return &r, nil
}
1361703
func (r Resource_Group) GetTemplate() (resp datatypes.Resource_Group_Template, err error) {
	err = r.Session.DoRequest("SoftLayer_Resource_Group", "getTemplate", nil, &r.Options, &resp)
	return
}
78944
func (a *Application) UsageTemplate(template string) *Application {
	a.usageTemplate = template
	return a
}
898277
func NewTemplate() *Template {
	return &Template{
		AWSTemplateFormatVersion: "2010-09-09",
		Description:              "",
		Metadata:                 map[string]interface{}{},
		Parameters:               map[string]interface{}{},
		Mappings:                 map[string]interface{}{},
		Conditions:               map[string]interface{}{},
		Resources:                Resources{},
		Outputs:                  map[string]interface{}{},
	}
}
1317423
func (q TemplateQuery) Template(name string) TemplateQuery {
	q.template = name
	return q
}
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
}
205412
func (b *Bar) Template(s string) {
	t, err := template.New("").Parse(s)
	if err != nil {
		panic(err)
	}

	b.tmpl = t
}
581543
func AddSourceTemplates(t *template.Template) {
	template.Must(t.Parse(`{{define "weblistcss"}}` + weblistPageCSS + `{{end}}`))
	template.Must(t.Parse(`{{define "weblistjs"}}` + weblistPageScript + `{{end}}`))
}
696769
func (s *Set) getTemplate(name, sibling string) (template *Template, err error) {
	name = path.Clean(name)

	if s.developmentMode {
		s.tmx.RLock()
		defer s.tmx.RUnlock()
		if newName, fileName, foundLoaded, foundFile, _ := s.resolveNameSibling(name, sibling); foundFile || foundLoaded {
			if foundFile {
				template, err = s.loadFromFile(newName, fileName)
			} else {
				template, _ = s.templates[newName]
			}
		} else {
			err = fmt.Errorf("template %s can't be loaded", name)
		}
		return
	}

	//fast path
	s.tmx.RLock()
	newName, fileName, foundLoaded, foundFile, isRelative := s.resolveNameSibling(name, sibling)

	if foundLoaded {
		template = s.templates[newName]
		s.tmx.RUnlock()
		if !isRelative && name != newName {
			// creates an alias
			s.tmx.Lock()
			if _, found := s.templates[name]; !found {
				s.templates[name] = template
			}
			s.tmx.Unlock()
		}
		return
	}
	s.tmx.RUnlock()

	//not found parses and cache
	s.tmx.Lock()
	defer s.tmx.Unlock()

	newName, fileName, foundLoaded, foundFile, isRelative = s.resolveNameSibling(name, sibling)
	if foundLoaded {
		template = s.templates[newName]
		if !isRelative && name != newName {
			// creates an alias
			if _, found := s.templates[name]; !found {
				s.templates[name] = template
			}
		}
	} else if foundFile {
		template, err = s.loadFromFile(newName, fileName)

		if !isRelative && name != newName {
			// creates an alias
			if _, found := s.templates[name]; !found {
				s.templates[name] = template
			}
		}

		s.templates[newName] = template
	} else {
		err = fmt.Errorf("template %s can't be loaded", name)
	}
	return
}
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
}
1085192
func Template(runOnStartup bool) POption {
	return func(p *POptions) {
		p.template = true
		p.runOnStartup = runOnStartup
	}
}
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
}
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
}
246243
func expandTemplate(tmpl string) (pkg string, err error) {
	pkg, err = template.DefaultExpander().Expand(tmpl)
	if err != nil {
		err = commandLineError{err}
	}
	return
}
131249
func (r *Registry) Template(name string) (Template, bool) {
	for _, t := range r.Templates {
		if t.Node.Name == name {
			return t, true
		}
	}
	return Template{}, false
}