예제 #1
0
// DefaultParser sets up and assigns the default parser to be used by Xslate.
func DefaultParser(tx *Xslate, args Args) error {
	syntax, ok := args.Get("Syntax")
	if !ok {
		syntax = "TTerse"
	}

	switch syntax {
	case "TTerse":
		tx.Parser = tterse.New()
	case "Kolon", "Kolonish":
		tx.Parser = kolonish.New()
	default:
		return errors.New("sytanx '" + syntax.(string) + "' is not available")
	}
	return nil
}
예제 #2
0
파일: xslate.go 프로젝트: shawnps/go-xslate
// DefaultParser sets up and assigns the default parser to be used by Xslate.
func DefaultParser(tx *Xslate, args Args) error {
	syntax, ok := args.Get("Syntax")
	if !ok {
		syntax = "TTerse"
	}

	switch syntax {
	case "TTerse":
		tx.Parser = tterse.New()
	case "Kolon", "Kolonish":
		tx.Parser = kolonish.New()
	default:
		return fmt.Errorf("error: Syntax '%s' not available", syntax)
	}
	return nil
}