示例#1
0
func listHelper(context interface{}, options *raymond.Options) string {
	val := reflect.ValueOf(context)
	switch val.Kind() {
	case reflect.Array, reflect.Slice:
		if val.Len() > 0 {
			result := "<ul>"
			for i := 0; i < val.Len(); i++ {
				result += "<li>"
				result += options.FnWith(val.Index(i).Interface())
				result += "</li>"
			}
			result += "</ul>"

			return result
		}
	}

	return "<p>" + options.Inverse() + "</p>"
}
示例#2
0
func formCtxHelper(context interface{}, options *raymond.Options) string {
	return "<form>" + options.FnWith(context) + "</form>"
}