Esempio n. 1
0
func detectDataHelper(options *raymond.Options) string {
	if val, ok := options.DataFrame().Get("exclaim").(string); ok {
		return val
	}

	return ""
}
Esempio n. 2
0
// isSuccess is a helper function that executes a block iff the status
// is success, else it executes the else block.
func isSuccess(conditional bool, options *raymond.Options) string {
	if !conditional {
		return options.Inverse()
	}

	switch options.ParamStr(0) {
	case "success":
		return options.Fn()
	default:
		return options.Inverse()
	}
}
Esempio n. 3
0
// isFailure is a helper function that executes a block iff the status
// is a form of failure, else it executes the else block.
func isFailure(conditional bool, options *raymond.Options) string {
	if !conditional {
		return options.Inverse()
	}

	switch options.ParamStr(0) {
	case "failure", "error", "killed":
		return options.Fn()
	default:
		return options.Inverse()
	}
}
Esempio n. 4
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>"
}
Esempio n. 5
0
func urlencode(options *raymond.Options) string {
	return url.QueryEscape(options.Fn())
}
Esempio n. 6
0
func formCtxHelper(context interface{}, options *raymond.Options) string {
	return "<form>" + options.FnWith(context) + "</form>"
}
Esempio n. 7
0
func formHelper(options *raymond.Options) string {
	return "<form>" + options.Fn() + "</form>"
}
Esempio n. 8
0
func rawThreeHelper(a, b, c string, options *raymond.Options) string {
	return options.Fn() + a + b + c
}
Esempio n. 9
0
func rawHelper(options *raymond.Options) string {
	return options.Fn()
}
Esempio n. 10
0
func linkHelper(prefix string, options *raymond.Options) string {
	return fmt.Sprintf(`<a href="%s/%s">%s</a>`, prefix, options.ValueStr("url"), options.ValueStr("text"))
}