Пример #1
0
// Parse parses the template definition string to construct an internal
// representation of the template for execution.
func (t *Template) Parse(s string) (tmpl *Template, err os.Error) {
	t.Tree, err = parse.New(t.name).Parse(s, t.leftDelim, t.rightDelim, t.parseFuncs, builtins)
	if err != nil {
		return nil, err
	}
	return t, nil
}
Пример #2
0
// ParseInSet parses the template definition string to construct an internal
// representation of the template for execution. It also adds the template
// to the set.
// Function bindings are checked against those in the set.
func (t *Template) ParseInSet(s string, set *Set) (tmpl *Template, err os.Error) {
	var setFuncs FuncMap
	if set != nil {
		setFuncs = set.parseFuncs
	}
	t.Tree, err = parse.New(t.name).Parse(s, t.leftDelim, t.rightDelim, t.parseFuncs, setFuncs, builtins)
	if err != nil {
		return nil, err
	}
	t.addToSet(set)
	return t, nil
}